Skip to content

Import files from cloud storage

POST/v5/files/cloud_imports

Register files that already exist in cloud blob storage as file records, in one batch.

Unlike upload, this transfers no bytes: each entry references an existing object by its container/bucket, filepath, filename, and MIME type, and only a metadata record pointing at that object is created. Files are imported independently and the response reports a per-file status. The response is 200 when every import succeeds and 207 when results are mixed, with each result marked SUCCESS or a failure reason (file does not exist, invalid permissions, or unknown error). Failed entries carry only the submitted filename and MIME type rather than a full file record.

Header ParametersExpand Collapse
"x-project-id": optional string
Body ParametersJSONExpand Collapse
files: array of object { container, file_type, filename, filepath }

List of files to import from cloud storage

container: string

The cloud storage container/bucket name

file_type: string

The MIME type of the file

filename: string

The name of the file

filepath: string

The path to the file within the container

ReturnsExpand Collapse
results: array of object { file, status }

Results for each file import attempt

file: SGPFile { id, created_at, created_by, 7 more } or object { filename, mime_type, object }

The file object (full File for success, minimal _FailedFile for failures)

One of the following:
SGPFile object { id, created_at, created_by, 7 more }
id: string

The unique identifier of the entity.

created_at: string

The date and time when the entity was created in ISO format.

formatdate-time
created_by: Identity { id, type, object }

The identity that created the entity.

id: string
type: "user" or "service_account"
One of the following:
"user"
"service_account"
object: optional "identity"
filename: string
md5_checksum: string
mime_type: string
size: number
duration_seconds: optional number
object: optional "file"
tags: optional map[unknown]
_FailedFile object { filename, mime_type, object }

Minimal file representation for failed uploads containing only essential information.

filename: string

The original filename from the request

mime_type: string

The original MIME type from the request

object: optional "failed_file"
status: "SUCCESS" or "FAILED_FILE_DOES_NOT_EXIST" or "FAILED_INVALID_PERMISSIONS" or "FAILED_UNKNOWN_ERROR"

The status of the upload attempt

One of the following:
"SUCCESS"
"FAILED_FILE_DOES_NOT_EXIST"
"FAILED_INVALID_PERMISSIONS"
"FAILED_UNKNOWN_ERROR"

Import files from cloud storage

curl https://api.egp.scale.com/v5/files/cloud_imports \
    -H 'Content-Type: application/json' \
    -H "x-api-key: $SGP_API_KEY" \
    -d '{
          "files": [
            {
              "container": "container",
              "file_type": "file_type",
              "filename": "filename",
              "filepath": "filepath"
            }
          ]
        }'
{
  "results": [
    {
      "file": {
        "id": "id",
        "created_at": "2019-12-27T18:11:19.117Z",
        "created_by": {
          "id": "id",
          "type": "user",
          "object": "identity"
        },
        "filename": "filename",
        "md5_checksum": "md5_checksum",
        "mime_type": "mime_type",
        "size": 0,
        "duration_seconds": 0,
        "object": "file",
        "tags": {
          "foo": "bar"
        }
      },
      "status": "SUCCESS"
    }
  ]
}
Returns Examples
{
  "results": [
    {
      "file": {
        "id": "id",
        "created_at": "2019-12-27T18:11:19.117Z",
        "created_by": {
          "id": "id",
          "type": "user",
          "object": "identity"
        },
        "filename": "filename",
        "md5_checksum": "md5_checksum",
        "mime_type": "mime_type",
        "size": 0,
        "duration_seconds": 0,
        "object": "file",
        "tags": {
          "foo": "bar"
        }
      },
      "status": "SUCCESS"
    }
  ]
}