signed_id, and pass that signed_id to the endpoint that uses the file:
- Upload the file with
POST /api/v3/admin/files(orPOST /api/v3/seller/filesin the Seller API). - Send the returned
signed_idto the endpoint that uses it — product media, an import, a logo, a document.
Uploading with the SDK
files.upload() does the whole upload and resolves to the response:
- SDK
- Spree CLI
file is any Blob or File — from a file input in the browser, or fs.openAsBlob(path) in Node.
Two ways to send the bytes
Both return the same response. Presigned (default). Send the file’s metadata as JSON, then send the bytes withupload.method (always PUT) to upload.url, carrying exactly upload.headers. The bytes go straight to storage, so use this for anything large. checksum is the file’s MD5 digest, base64-encoded; storage checks the bytes against it.
- SDK
- cURL
file part of the request itself. The file is stored before the response, so upload is null. No checksum is needed, but the size limit is lower. This suits scripts and tools that cannot make a second request.
- SDK
- cURL
The response
signed_idis opaque. Pass it back unchanged and never parse it.- It expires at
expires_at, one day after the upload. An expired or alteredsigned_idis refused with a422; upload the file again. - The file belongs to your store. A file uploaded in one store is meant to be used in that store only.
Visibility
Attaching a file never moves it between public and private storage, so choose when you upload. Each endpoint still checks the file it receives, so a digital product can be any type while a logo must be an image.
Size limits
Parameter names
Every parameter that takes an upload is namedsigned_id or <name>_signed_id, after the file it sets: avatar_signed_id, logo_signed_id, image_signed_id, attachment_signed_id, document_signed_id, file_signed_id, po_document_signed_id. Send null to remove a file, or leave the key out to keep it.
Files that are never used
A file uploaded through the files endpoint that is never attached to anything is deleted after two days bySpree::Uploads::PurgeUnattachedJob. Files that belong to no store, such as files from before the 6.0 upgrade that were never attached, are left alone. Schedule it daily (see the upgrade guide). Change the period with Spree::Config.unattached_upload_retention_days or SPREE_UNATTACHED_UPLOAD_RETENTION_DAYS.
Image URLs are opaque too
Image URLs in responses (original_url, small_url, …) can change host or format, for example when a store moves to a CDN. Store and render them as given; never build or parse them.
