# Files ## List files `client.Files.List(ctx, query) (*CursorIDPage[File], error)` **get** `/v1/files` List all files uploaded by the current user. ### Parameters - `query FileListParams` - `After param.Field[string]` A cursor for pagination. Use the `last_id` from a previous response to fetch the next page. - `Limit param.Field[int64]` Maximum number of files to return. ### Returns - `type File struct{…}` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `ID string` The unique identifier for this file. - `ContentType string` The MIME type of the file. - `CreatedAt Time` The timestamp when the file was uploaded. - `FileName string` The original filename of the uploaded file. - `Object File` The object type, which is always 'file'. - `const FileFile File = "file"` - `Size int64` The size of the file in bytes. ### Example ```go package main import ( "context" "fmt" "github.com/deeptable-com/deeptable-go" "github.com/deeptable-com/deeptable-go/option" ) func main() { client := deeptable.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.Files.List(context.TODO(), deeptable.FileListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "data": [ { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "created_at": "2024-01-15T10:30:00Z", "file_name": "financial_report.xlsx", "object": "file", "size": 1048576 } ], "has_more": false, "object": "list", "first_id": "file_01kfxgjd94fn9stqm414vjb0s8", "last_id": "file_01kfxgjd94fn9stqm414vjb0s8" } ``` ## Upload a file `client.Files.Upload(ctx, body) (*File, error)` **post** `/v1/files` Upload an Excel spreadsheet file for later processing. Supported formats: - Excel (.xlsx) Maximum file size: 100 MB ### Parameters - `body FileUploadParams` - `File param.Field[Reader]` The spreadsheet file to upload ### Returns - `type File struct{…}` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `ID string` The unique identifier for this file. - `ContentType string` The MIME type of the file. - `CreatedAt Time` The timestamp when the file was uploaded. - `FileName string` The original filename of the uploaded file. - `Object File` The object type, which is always 'file'. - `const FileFile File = "file"` - `Size int64` The size of the file in bytes. ### Example ```go package main import ( "bytes" "context" "fmt" "io" "github.com/deeptable-com/deeptable-go" "github.com/deeptable-com/deeptable-go/option" ) func main() { client := deeptable.NewClient( option.WithAPIKey("My API Key"), ) file, err := client.Files.Upload(context.TODO(), deeptable.FileUploadParams{ File: io.Reader(bytes.NewBuffer([]byte("Example data"))), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", file.ID) } ``` #### Response ```json { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "created_at": "2024-01-15T10:30:00Z", "file_name": "financial_report.xlsx", "object": "file", "size": 1048576 } ``` ## Delete a file `client.Files.Delete(ctx, fileID) (*FileDeleteResponse, error)` **delete** `/v1/files/{file_id}` Delete a file. This cannot be undone. ### Parameters - `fileID string` The unique identifier of the file. ### Returns - `type FileDeleteResponse struct{…}` Response from deleting a file. Following the OpenAI API convention for delete responses. - `ID string` The unique identifier of the deleted file. - `Deleted bool` Whether the file was successfully deleted. - `const FileDeleteResponseDeletedTrue FileDeleteResponseDeleted = true` - `Object File` The object type, which is always 'file'. - `const FileFile File = "file"` ### Example ```go package main import ( "context" "fmt" "github.com/deeptable-com/deeptable-go" "github.com/deeptable-com/deeptable-go/option" ) func main() { client := deeptable.NewClient( option.WithAPIKey("My API Key"), ) file, err := client.Files.Delete(context.TODO(), "file_01kfxgjd94fn9stqm414vjb0s8") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", file.ID) } ``` #### Response ```json { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "deleted": true, "object": "file" } ``` ## Get file metadata `client.Files.Get(ctx, fileID) (*File, error)` **get** `/v1/files/{file_id}` Get metadata for a specific file. ### Parameters - `fileID string` The unique identifier of the file. ### Returns - `type File struct{…}` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `ID string` The unique identifier for this file. - `ContentType string` The MIME type of the file. - `CreatedAt Time` The timestamp when the file was uploaded. - `FileName string` The original filename of the uploaded file. - `Object File` The object type, which is always 'file'. - `const FileFile File = "file"` - `Size int64` The size of the file in bytes. ### Example ```go package main import ( "context" "fmt" "github.com/deeptable-com/deeptable-go" "github.com/deeptable-com/deeptable-go/option" ) func main() { client := deeptable.NewClient( option.WithAPIKey("My API Key"), ) file, err := client.Files.Get(context.TODO(), "file_01kfxgjd94fn9stqm414vjb0s8") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", file.ID) } ``` #### Response ```json { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "created_at": "2024-01-15T10:30:00Z", "file_name": "financial_report.xlsx", "object": "file", "size": 1048576 } ``` ## Download file `client.Files.Download(ctx, fileID) (*Response, error)` **get** `/v1/files/{file_id}/content` Download the original uploaded file content. ### Parameters - `fileID string` The unique identifier of the file. ### Returns - `type FileDownloadResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/deeptable-com/deeptable-go" "github.com/deeptable-com/deeptable-go/option" ) func main() { client := deeptable.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.Files.Download(context.TODO(), "file_01kfxgjd94fn9stqm414vjb0s8") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` ## Domain Types ### File - `type File struct{…}` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `ID string` The unique identifier for this file. - `ContentType string` The MIME type of the file. - `CreatedAt Time` The timestamp when the file was uploaded. - `FileName string` The original filename of the uploaded file. - `Object File` The object type, which is always 'file'. - `const FileFile File = "file"` - `Size int64` The size of the file in bytes.