Create an upload
client.uploads.create(UploadCreateParams { metadata, spec } body, RequestOptionsoptions?): Upload { info, metadata, spec }
POST/v1/uploads
Issues a short-lived presigned URL for direct upload to object storage. The returned id is used to reference the upload from resources that accept binary content.
Create an upload
import Cadenya from '@cadenya/cadenya';
const client = new Cadenya({
apiKey: process.env['CADENYA_API_KEY'], // This is the default and can be omitted
});
const upload = await client.uploads.create({
metadata: { name: 'name' },
spec: {
contentType: 'contentType',
filename: 'filename',
sizeBytes: 'sizeBytes',
},
});
console.log(upload.info);{
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_USER",
"email": "email",
"name": "name"
}
},
"status": "UPLOAD_STATUS_UNSPECIFIED",
"uploadUrl": "uploadUrl",
"uploadUrlExpiresAt": "2019-12-27T18:11:19.117Z"
},
"metadata": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"contentType": "contentType",
"filename": "filename",
"sizeBytes": "sizeBytes"
}
}Returns Examples
{
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_USER",
"email": "email",
"name": "name"
}
},
"status": "UPLOAD_STATUS_UNSPECIFIED",
"uploadUrl": "uploadUrl",
"uploadUrlExpiresAt": "2019-12-27T18:11:19.117Z"
},
"metadata": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"contentType": "contentType",
"filename": "filename",
"sizeBytes": "sizeBytes"
}
}