Skip to main content
POST
/
lucca-files
/
api
/
uploads
Upload a file
curl --request POST \
  --url https://{host}/lucca-files/api/uploads \
  --header 'Accept: <accept>' \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: multipart/form-data' \
  --form form='@example-file'
import requests

url = "https://{host}/lucca-files/api/uploads"

files = { "form": ("example-file", open("example-file", "rb")) }
headers = {
    "Accept": "<accept>",
    "Authorization": "<authorization>"
}

response = requests.post(url, files=files, headers=headers)

print(response.text)
const form = new FormData();
form.append('form', '<string>');

const options = {
  method: 'POST',
  headers: {Accept: '<accept>', Authorization: '<authorization>'}
};

options.body = form;

fetch('https://{host}/lucca-files/api/uploads', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://{host}/lucca-files/api/uploads",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"form\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
  CURLOPT_HTTPHEADER => [
    "Accept: <accept>",
    "Authorization: <authorization>",
    "Content-Type: multipart/form-data"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{host}/lucca-files/api/uploads"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"form\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "<accept>")
	req.Header.Add("Authorization", "<authorization>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://{host}/lucca-files/api/uploads")
  .header("Accept", "<accept>")
  .header("Authorization", "<authorization>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"form\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://{host}/lucca-files/api/uploads")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = '<accept>'
request["Authorization"] = '<authorization>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"form\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "deletedAt": "<string>",
  "contentLength": 2,
  "extension": "<string>",
  "totalPages": 1
}

Headers

Accept
string
required

HTTP request header used for content-negotiation.

Allowed value: "application/json"
Content-Type
string
required

HTTP response header used for content-negotiation.

Allowed value: "multipart/form-data"
Authorization
string
required

API key. Value must be formatted like so: lucca application={api_key}.

Body

multipart/form-data
form
file

Response

201 - application/json

Created

A file resource.

id
string<uuid>
name
string

File name.

createdAt
string<date-time>

UTC timestamp of the moment this file was uploaded.

deletedAt
string | null

UTC timestamp of the moment this file was deleted. When null, file is not deleted.

contentLength
integer

File size in bytes.

Required range: x >= 1
contentType
enum<string>
Available options:
eml message/rfc822,
image/heic,
image/heif,
image/jpe,
image/jpg,
image/pjpeg,
image/gif,
image/bmp,
image/tif,
image/tiff,
image/x-dcraw,
image/x-jb2,
image/x-jbig2,
image/x-jpf,
image/x-ms-bmp,
image/x-panasonic-raw,
image/x-pcx,
image/x-icon,
image/x-png,
image/vnd.microsoft.icon,
image/webp,
image/x-portable-anymap,
text/plain,
text/csv,
text/rtf,
text/calendar,
text/comma-separated-values,
text/markdown,
application/pdf,
application/msword,
application/xls,
application/x-csv,
application/ms-excel,
application/vnd.ms-office,
application/vnd.ms-word,
application/vnd.ms-outlook,
application/vnd.ms-powerpoint,
application/vnd.ms-excel,
application/vnd.oasis.opendocument.text,
application/vnd.oasis.opendocument.spreadsheet,
application/vnd.oasis.opendocument.presentation,
application/vnd.oasis.opendocument.graphics,
application/vnd.openxmlformats-officedocument.wordprocessingml.document,
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
application/vnd.openxmlformats-officedocument.presentationml.presentation,
application/vnd.openxmlformats-officedocument.presentationml.slideshow,
application/vnd.openxmlformats-officedocument.presentationml.template,
application/x-7z-compressed,
application/rar,
application/x-rar,
application/zip,
application/csv,
application/rtf,
application/text,
application/txt,
application/x-pdf
extension
string

Inferred from content-type (e.g.: '.pdf', '.doc', '.txt', etc...).

totalPages
integer

Number of pages of a document file.

Required range: x >= 0