Skip to content

Get file metadata

client.Files.Get(ctx, fileID, query) (*SGPFile, error)
GET/v5/files/{file_id}

Retrieve a single file’s metadata by id.

Returns the file record (id, filename, MIME type, size, tags, and related fields) but not the file’s bytes; use the content endpoint to download the bytes.

ParametersExpand Collapse
fileID string
query FileGetParams
XProjectID param.Field[string]Optional
ReturnsExpand Collapse
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.

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Filename string
Md5Checksum string
MimeType string
Size int64
DurationSeconds int64Optional
Object SGPFileObjectOptional
Tags map[string, any]Optional

Get file metadata

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"),
  )
  sgpFile, err := client.Files.Get(
    context.TODO(),
    "file_id",
    sgpdev.FileGetParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sgpFile.ID)
}
{
  "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"
  }
}
Returns Examples
{
  "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"
  }
}