Class: Ecoportal::API::GraphQL::Mutation::FileContainer::Upload

Inherits:
Logic::Mutation
  • Object
show all
Defined in:
lib/ecoportal/api/graphql/mutation/file_container/upload.rb

Overview

Registers an object already uploaded to S3 as an org file container.

★ This is the REAL second half of a file upload, captured from the web client on 2026-07-30 (tmp/file_upload_network_log.har): the browser does FileSignature (GraphQL) -> S3 multipart POST -> uploadFile (GraphQL) -> updatePage. There is NO POST /api/v2/<org>/s3/files call and NO polling step — the previous implementation was a port of ecoportal-api-v2's REST S3 code and targeted endpoints the platform does not use for this flow.

url is the S3 object key returned by the upload step (NOT a URL, despite the name — verified against the capture: uploads/<userId>/<stamp>-<token>-/<filename>).

Verified against the live schema (2026-07-30):

uploadFile(input: UploadInput) -> UploadPayload { clientMutationId errors item: FileContainer }
UploadInput { clientMutationId filename filetype filesize locationIds otherTags url containerId }

Instance Method Summary collapse

Methods inherited from Logic::Mutation

#response_class

Instance Method Details

#query(filename:, filetype:, filesize:, url:, location_ids: nil, other_tags: nil, container_id: nil, client_mutation_id: nil, **kargs, &block) ⇒ Object

Parameters:

  • filename (String) —

    the file's base name as it should appear in the manager.

  • filetype (String) —

    MIME type.

  • filesize (Integer, String) —

    bytes. The schema types this as String.

  • url (String) —

    the S3 object KEY produced by the S3 POST step.

  • location_ids (Array<String>, nil) (defaults to: nil) —

    locations to file it under.

  • other_tags (Array<String>, nil) (defaults to: nil) —

    tags — the only supported way to tag a container (there is no separate tag mutation; confirmed 2026-07-30).

  • container_id (String, nil) (defaults to: nil) —

    add a new VERSION to an existing container.

  • client_mutation_id (String, nil) (defaults to: nil) —

    optional correlation/tracing id -- UploadInput's own clientMutationId (confirmed in this file's own header, UploadInput { clientMutationId filename filetype filesize locationIds otherTags url containerId }). Omitted entirely when not given, so every existing caller's input shape is byte-identical to before.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ecoportal/api/graphql/mutation/file_container/upload.rb', line 39

def query(filename:, filetype:, filesize:, url:, location_ids: nil, other_tags: nil,
          container_id: nil, client_mutation_id: nil, **kargs, &block)
  input = {
    filename: filename,
    filetype: filetype,
    filesize: filesize.to_s,
    url:      url
  }
  input[:locationIds]      = Array(location_ids) if location_ids
  input[:otherTags]        = Array(other_tags)   if other_tags
  input[:containerId]      = container_id        if container_id
  input[:clientMutationId] = client_mutation_id  unless client_mutation_id.nil?

  super(input: input, **kargs, &block)
end