Simple Uploads
Introduction
Simple uploads are 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.
If you know you need to handle very large files (4GB+) or your users are prone to unstable internet connections, you may want to look at resumable uploads.
How it works
At its most basic, 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.
Upload handler
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.
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.
You should never include your API key in client-side code. If you're uploading from a client app, take a look at signed uploads.
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.
Footnotes
-
You get a free
*.ittybit.net
domain when you create a project. You can also add Custom Domains in your project settings. ↩