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
header
x-api-key<token>Workspace API key, sent in the x-api-key header. Keys start with op_ and are created in the dashboard.
application/json- body
filename*stringName of the file you will upload.
Length
1 <= length <= 255contentType*stringMIME type of the file. Send the same value as the Content-Type header of the upload.
Length
1 <= length <= 127Upload URL created
application/json- response
uploadUrl*stringURL to upload the file to with a PUT request.
Format
uripublicUrl*stringURL of the file after upload. Use it in mediaUrls.
Format
urikey*stringStorage key of the uploaded file.
expiresIn*numberSeconds 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}