Uploads
Introduction
You can upload files to your project to Store them securely, make them readily available for Tasks, and to Deliver them to your users.
There are three ways to upload files to your project:
Simple uploads
Simple uploads are – as the name suggests – the easiest way to upload files to your project.
They're a great fit for many use cases, and often the ideal place to start when first adding file uploads to your app.
How it works
You make an authenticated PUT
request to the url you want to serve the file from.
You pass the bytes of the file in the request body.
When the upload completes, ittybit will return a File object in the response.
Authentication
If you already have the file on your server (or in a server route or serverless function), then you can authenticate the request with your API Key.
If you're uploading from a client app, take a look at signed uploads.
You should never include your API key in client-side code.
Example
For example, if your project's delivery domain is https://example.ittybit.net
1, and you want to call the file image.png
, then you'd make a PUT
request to https://example.ittybit.net/image.png
.
The filename
and folder
will be inferred from the url.
File object
When your upload completes, ittybit will return a File object in the response.
The meta
object contains information about the request.
The data
object contains the file object.
You can persist this info to your database, and use it to serve the file to your users.
The error
object will only be present if the upload failed.
Resumable uploads
If you need to handle larger files (100MB+), or your users are prone to unstable internet connections, then we recommend using resumable uploads.
This breaks the file into chunks and sends them to the server separately. It means you can send chunks in parallel, and if one chunk fails, you can retry that chunk without having to restart the whole upload.
File size limits are based on your org's billing status and plan. If you receive 413 Request Entity Too Large
errors, please contact us and we can increase your limit.
How it works
You send smaller pieces of the file (chunks) to the server across multiple requests.
You add a Content-Range
header which covers the byte range that is being sent.
If it's the final chunk, we combine the chunks and return a File object
Example
The basic request is very similar to simple uploads.
For example, to send the first 16MB of a 100MB file:
Then, you send the next chunk:
And so on, until you've sent all the chunks.
If it's the final chunk (we work this out from the Content-Range
header value), then we will check that we have all the chunks available, and we will process the full file:
Media library
If you just need to quickly add a file or two, you can use the media library from the ittybit dashboard.
Drag-and-drop files onto the window, or use the 'Add Files' button to start an upload.
Footnotes
-
You get a free
*.ittybit.net
domain when you create a project. You can also add Custom Domains in your project settings. ↩