Upload a file
client.Files.New(ctx, body) (*CreateFileResponse, error)
POST/files
Upload a file to your namespace, then reference it from a generation via ImageRef.file_id (as source, image_ref[], video.start_frame, keyframes, and so on). Two upload modes share this endpoint, selected by Content-Type:
-
multipart/form-data — send the bytes inline in the
filepart. Best for small files (subject to an inline size cap; larger files must use the presigned flow). The returned file is alreadypendingingest. -
application/json — request a presigned upload. The response
uploadenvelope tells you where to PUT the bytes; afterward call POST /files/{file_id}/complete to start ingest. Use this for larger files.
Parameters
Returns
Upload a file
package main
import ( "context" "fmt"
"github.com/lumalabs/luma-agents-go" "github.com/lumalabs/luma-agents-go/option")
func main() { client := lumaagents.NewClient( option.WithAuthToken("My Auth Token"), ) createFileResponse, err := client.Files.New(context.TODO(), lumaagents.FileNewParams{ MimeType: lumaagents.F("x"), SizeBytes: lumaagents.F(int64(1)), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", createFileResponse.ID)}201 example
{ "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "file": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "mime_type": "mime_type", "purpose": "input", "size_bytes": 0, "state": "pending", "deleted_at": "2019-12-27T18:11:19.117Z", "expires_at": "2019-12-27T18:11:19.117Z", "failure_reason": "failure_reason", "filename": "filename", "user_id": "user_id" }, "state": "pending", "upload": { "expires_at": "2019-12-27T18:11:19.117Z", "method": "method", "url": "https://example.com", "headers": { "foo": "string" } }}Returns Examples
201 example
{ "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "file": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "mime_type": "mime_type", "purpose": "input", "size_bytes": 0, "state": "pending", "deleted_at": "2019-12-27T18:11:19.117Z", "expires_at": "2019-12-27T18:11:19.117Z", "failure_reason": "failure_reason", "filename": "filename", "user_id": "user_id" }, "state": "pending", "upload": { "expires_at": "2019-12-27T18:11:19.117Z", "method": "method", "url": "https://example.com", "headers": { "foo": "string" } }}