Import files from cloud storage
client.Files.ImportFromCloud(ctx, params) (*FileImportFromCloudResponse, error)
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.
Import files from cloud storage
package main
import (
"context"
"fmt"
"github.com/scaleapi/sgp-dev-go"
"github.com/scaleapi/sgp-dev-go/option"
)
func main() {
client := sgpdev.NewClient(
option.WithAPIKey("My API Key"),
option.WithAccountID("My Account ID"),
)
response, err := client.Files.ImportFromCloud(context.TODO(), sgpdev.FileImportFromCloudParams{
Files: []sgpdev.FileImportFromCloudParamsFile{sgpdev.FileImportFromCloudParamsFile{
Container: "container",
FileType: "file_type",
Filename: "filename",
Filepath: "filepath",
}},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Results)
}
{
"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"
}
]
}