Simple-Upload

FREEMIUM
By Omar Foudane | Updated एक महीने पहले | Data
Popularity

5.4 / 10

Latency

119ms

Service Level

100%

Health Check

N/A

README

Simple-Upload

Introduction

Our API allows users to upload files from their application to the Cloud without worrying about the infrasturcture costs. We offer our users the capability to securely upload files directly from the end user’s device (mobile application/browser). This is possible thanks to a one-time presigned URL, generated by your backend application to upload a specific type of assets (image, audio or document).

How to upload a file:

Our API allows users to upload files from the frontend application. To do so securely, the user should:

  1. Generate a one-time usage URL from our Rapid API endpoint /upload/one-time:
curl --location 'https://simple-upload1.p.rapidapi.com/upload/one-time' \
--header 'Content-Type: application/json' \
--header 'X-RapidAPI-Key': '`YOUR_RAPID_API_KEY',\
--data '{
  "type": "Image"
} 
  1. The API will generate a link that can be used one time to upload 1 file. The generated link does not go through Rapid API platform, so no need to attach any secret credentials to it. The URL is protected by a long token. Following is an example using javascript on “File” input field with the id “image-input”
// This is the URL generated in step 1
const oneTimeUploadURL = "{GENERATED_URL_FROM_STEP_1}";
const fileInput = document.getElementById("image-input");
if(!fileInput || !fileInput.files?.[0]) throw new Error("Please select a file first")
const formData = new FormData();
formData.append("file", fileInput.files[0]);
const response = await fetch(oneTimeUploadURL, { body: formData, method: "POST" });
if(response.status === 200) {
    // The file uploaded succesfully
    const responseObj = await response.json();
    // You can now save this URL on your database and use as a reference to your images/audios on your website
    const myDownloadURL = responseObj.url;
} else if(status < 500){
    // Bad request (e.g: File size cannot exceed 10 MB)
    const { reason } = await response.json();
    throw new Error("Failed to upload the file for the following reason: " + reason);
} else {
    // Some unexpected error happened. Please report these errors to us, so we can ensure they do not occur again
    throw new Error("Unexpected error: "+ await response.text());
}
  1. Use the download URL in your website. For instance, if the uploaded file is an image, then you can use the generated URL in step 2 in the src attribute. Here is an example: <img width="100" src="https://rapidapi-storage.easier-api.com/public/test/randomTest/fdb4eab8-6765-ec33-adf3-27011ea42d04.jpg">
Followers: 2
API Creator:
Rapid account: Omar Foudane
Omar Foudane
ofoudane
Log In to Rate API
Rating: 5 - Votes: 1