Backend API
Updates an existing file using the ID that was returned when created. Updating performs a merge operation. To explicitly override values such as arrays, use the $set operator.
Arguments
idobjectIdrequired
The id of the file you wish to update.
datafiledata
File content, base64-encoded when created or updated through the API.
filenamestring
The name of the uploaded file.
aliasesarray of String
An array of alternative names or aliases associated with the file.
metadataobject
Arbitrary data for storing additional information about the file.
privateboolean
Indicates the file is private and not served publicly from the CDN.
widthint
The width dimension of the file, applicable for image files.
heightint
The height dimension of the file, applicable for image files.
PUT/:files
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.put('/:files/{id}', {
id: '6595457d82e01f0012243057',
width: 1200,
// use $set to override values
$set: {
metadata: {
...
},
},
});The file model
{
"length": 4898,
"chunkSize": 261120,
"uploadDate": "2024-01-03T11:31:09.153Z",
"filename": "image.jpg",
"content_type": "image/jpeg",
"date_created": "2024-01-03T11:31:09.143Z",
"date_uploaded": "2024-01-03T11:31:09.158Z",
"md5": "f082a5c3677bb757e11d738cb6f60624",
"url": "https://cdn.swell.store/f082a5c3677bb757e11d738cb6f60624/image.jpg",
"width": 1200,
"id": "6595457d82e01f0012243057"
}