Skip to content

Init File Storage

POST /public/storage/file/init

Initialize a file upload session. Provide the filename, file size, and MIME type to create an upload session. The response includes an upload URL where the file should be uploaded directly using a PUT request.

Endpoint Details

  • Authentication: Basic Auth (Authorization: Basic Base64(AccessKey:SecretKey))
  • Access Tier: Addon Storage

Request Body

FieldTypeRequiredDescription
filenamestringYesName of the file to upload.
sizenumberYesFile size in bytes.
mimetypestringYesMIME type of the file (e.g. video/mp4, image/png).

Example Request

bash
curl -X POST "https://api.repliz.com/public/storage/file/init" \
  -H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)" \
  -H "Content-Type: application/json" \
  -d '{"filename":"video.mp4","size":102400,"mimetype":"video/mp4"}'
javascript
import axios from "axios";

const response = await axios.post(
  "https://api.repliz.com/public/storage/file/init",
  {
    filename: "video.mp4",
    size: 102400,
    mimetype: "video/mp4",
  },
  {
    auth: {
      username: "YOUR_ACCESS_KEY",
      password: "YOUR_SECRET_KEY",
    },
  },
);

console.log(response.data);
javascript
const credentials = btoa("YOUR_ACCESS_KEY:YOUR_SECRET_KEY");

const response = await fetch(
  "https://api.repliz.com/public/storage/file/init",
  {
    method: "POST",
    headers: {
      Authorization: `Basic ${credentials}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      filename: "video.mp4",
      size: 102400,
      mimetype: "video/mp4",
    }),
  },
);

const data = await response.json();
console.log(data);

Response

json
{
  "id": "6a4c3a3bc4586b1f1ce483e4",
  "upload": "https://repliz.2ca853e78c4cd1a89797e3d770c7ca9f.r2.cloudflarestorage.com/uploads/6879b98097fc8c8a78d1d4c1/0dcb2544-bbc8-4b42-a2e3-0449133ef58f.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&...",
  "key": "uploads/6879b98097fc8c8a78d1d4c1/0dcb2544-bbc8-4b42-a2e3-0449133ef58f.mp4",
  "url": "https://storage.repliz.com/uploads/6879b98097fc8c8a78d1d4c1/0dcb2544-bbc8-4b42-a2e3-0449133ef58f.mp4"
}
json
{
  "code": 429,
  "message": "upgrade to get more storage"
}
json
{
  "code": 401,
  "message": "unauthorized"
}