Media

Get a Presigned Upload URL

Returns a URL you upload a file to directly with a PUT request. Send the same Content-Type you declared, then use publicUrl in your post.

POST
/v1/media/presign

Authorization

headerx-api-key<token>

Workspace API key, sent in the x-api-key header. Keys start with op_ and are created in the dashboard.

Request Body

application/json
  1. body
filename*string

Name of the file you will upload.

Length1 <= length <= 255
contentType*string

MIME type of the file. Send the same value as the Content-Type header of the upload.

Length1 <= length <= 127

Response Body

Upload URL created

application/json
  1. response
uploadUrl*string

URL to upload the file to with a PUT request.

Formaturi
publicUrl*string

URL of the file after upload. Use it in mediaUrls.

Formaturi
key*string

Storage key of the uploaded file.

expiresIn*number

Seconds until uploadUrl expires.

Example Request
import { Configuration, MediaApi } from "@onepostly/sdk";const mediaApi = new MediaApi(  new Configuration({ apiKey: process.env.ONEPOSTLY_API_KEY }));const response = await mediaApi.getMediaPresignedUrl({  presignMediaBody: {    "filename": "photo.jpg",    "contentType": "image/jpeg"  },});console.log(response);
Example Response
{  "uploadUrl": "http://example.com",  "publicUrl": "http://example.com",  "key": "string",  "expiresIn": 0}