Skip to main content
You can upload data to the sandbox using the files.write() method.

Upload single file

Stream an upload

Instead of reading a whole file into memory first, pass a stream (or an iterable of byte chunks) to files.write(). Chunks are uploaded as they arrive, so the size of the data doesn’t matter.
Streams are always uploaded as application/octet-stream and are never buffered, so useOctetStream: false (use_octet_stream=False in Python) raises an error for them. gzip: true compresses the stream on the fly.
Sandbox accepts sync iterables and AsyncSandbox accepts async iterables. In browsers that can’t stream request bodies (Firefox, Safari), convert the stream to a Blob first, for example await new Response(stream).blob().

Upload with pre-signed URL

Sometimes, you may want to let users from unauthorized environments, like a browser, upload files to the sandbox. For this use case, you can use pre-signed URLs to let users upload files securely. Every sandbox has secured access enabled, so all you need to do is generate a URL with a signature that allows only authorized users to upload files. You can optionally set an expiration time for the URL so that it will be valid only for a limited time.

Upload directory / multiple files