Need some storage online for a simple or prototype project? I gotchuuu!
A Bucket is like an actual bucket, wherein you can put your stuff in.
A Bucket can hold multiple images.
Go to the Create Page, and this will return a bucket URL that'll use to upload image.
This is the result of the creation, the upload_url.
{
upload_url: "https://bucket.smollbites.com/YOUR_BUCKET_ID/upload"
}
In uploading, use the upload_url from step 1. Create an input field
<input id="fileInput" type="file" />
And, now upload the file
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
const formData = new FormData()
formData.append('file', file);
fetch('https://bucket.smollbites.com/YOUR_BUCKET_ID/upload ', {
method: "POST",
body: formData
})
.then((response) => response.json())
.then((response) => {
console.log(response);
/**
* {
* success: true,
* path: "....com/YOUR_BUCKET_ID/YOUR_IMAGE_ID.png"
* }
*/
})
That's it, congrats!
This is the simple workflow, I created this because, as of writing this documentation, I want to do some designing
As of now, the maximum file size is 10mb and JPG, JPEG, PNG are the only files allowed. Let's see soon if I can support intergalactic file extensions. Let's see.