POST
/
upload
async function uploadFile(file) {
  const uploadEndpoint = "https://api.uploadfly.cloud/upload";
  try {
    // Create a new FormData object
    const formData = new FormData();

    // Append the file to the FormData object with the key 'file'
    formData.append("file", file);

    // Make the POST request using the fetch API
    const response = await fetch(uploadEndpoint, {
      method: "POST",
      body: formData,
      headers: {
        Authorization: "Bearer API_KEY",
      },
    });

    // Handle response
  } catch (error) {
    // Handle error
  }
}

// Example usage:
const fileInput = document.getElementById("fileInput"); // Assuming you have an input element with type="file" and id="fileInput" in your HTML
fileInput.addEventListener("change", (event) => {
  const file = event.target.files[0];
  uploadFile(file);
});
{
  "success": true,
  "status": 200,
  "data": {
    "url": "https://cdn.uploadfly.cloud/loUvT2/example-uwAyQV.png",
    "path": "loUvT2/example-uwAyQV.png",
    "type": "image/png",
    "size": "21.55 kB",
    "name": "example-uwAyQV"
  }
}

Body

file
file
required

This is the file that is going to be uploaded to your fly.

filename
string

This is the name of your file

maxFileSize
string

This is the maximum file size that can be uploaded. For example: 1MB

allowedFileTypes
string

This are the file types that can be uploaded. Multiple file types should be separated with commas. For example: mp4, png, wav

Response

success
boolean

Indicates whether the call was successful. true if successful, false if not.

status
number

Provides additional information about the outcome of the request. The specific values and their meanings may vary.

  • 200: The request was successful.
  • 400: The request was invalid or malformed.
  • 401: Authentication or authorization failed.
  • 403: The request is not allowed.
  • 404: The requested resource was not found.
  • 500: An internal server error occurred.
data
object

This contains information about the uploaded file such as the url, file size, path and mime type.