## 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.

### Parameters

- `params FileImportFromCloudParams`

  - `Files param.Field[[]FileImportFromCloudParamsFile]`

    Body param: List of files to import from cloud storage

    - `Container string`

      The cloud storage container/bucket name

    - `FileType string`

      The MIME type of the file

    - `Filename string`

      The name of the file

    - `Filepath string`

      The path to the file within the container

  - `XProjectID param.Field[string]`

    Header param

### Returns

- `type FileImportFromCloudResponse struct{…}`

  - `Results []FileImportFromCloudResponseResult`

    Results for each file import attempt

    - `File FileImportFromCloudResponseResultFileUnion`

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

      - `type SGPFile struct{…}`

        - `ID string`

          The unique identifier of the entity.

        - `CreatedAt Time`

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

        - `CreatedBy Identity`

          The identity that created the entity.

          - `ID string`

          - `Type IdentityType`

            - `const IdentityTypeUser IdentityType = "user"`

            - `const IdentityTypeServiceAccount IdentityType = "service_account"`

          - `Object IdentityObject`

            - `const IdentityObjectIdentity IdentityObject = "identity"`

        - `Filename string`

        - `Md5Checksum string`

        - `MimeType string`

        - `Size int64`

        - `DurationSeconds int64`

        - `Object SGPFileObject`

          - `const SGPFileObjectFile SGPFileObject = "file"`

        - `Tags map[string, any]`

      - `type FileImportFromCloudResponseResultFile_FailedFile struct{…}`

        Minimal file representation for failed uploads containing only essential information.

        - `Filename string`

          The original filename from the request

        - `MimeType string`

          The original MIME type from the request

        - `Object string`

          - `const FileImportFromCloudResponseResultFile_FailedFileObjectFailedFile FileImportFromCloudResponseResultFile_FailedFileObject = "failed_file"`

    - `Status string`

      The status of the upload attempt

      - `const FileImportFromCloudResponseResultStatusSuccess FileImportFromCloudResponseResultStatus = "SUCCESS"`

      - `const FileImportFromCloudResponseResultStatusFailedFileDoesNotExist FileImportFromCloudResponseResultStatus = "FAILED_FILE_DOES_NOT_EXIST"`

      - `const FileImportFromCloudResponseResultStatusFailedInvalidPermissions FileImportFromCloudResponseResultStatus = "FAILED_INVALID_PERMISSIONS"`

      - `const FileImportFromCloudResponseResultStatusFailedUnknownError FileImportFromCloudResponseResultStatus = "FAILED_UNKNOWN_ERROR"`

### Example

```go
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)
}
```

#### Response

```json
{
  "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"
    }
  ]
}
```
