Get Upload Policy

POSThttps://api.newportai.com/api/file/v1/get_policy

The Get Upload Policy API provides the necessary authentication parameters and destination details required for the Upload API. While our AI services can fetch files from your own servers, using our optimized Storage service ensures faster, more stable downloads for large or slow-loading files.

Note on Storage: This service is provided free of charge to support AI processing. Uploaded files are intended for temporary use and are guaranteed to be available for at least one day.

  • Submit a POST request to retrieve a short-lived upload policy and signature.
  • Use the returned data object to authorize your direct upload to the cloud storage bucket.

Request Headers

Content-Type string Required

Enum: application/json

Authorization string Required

Bearer authentication token. Example: Bearer {{APIKey}}.

Request Body

scene string Required

The upload scenario which determines the storage strategy. Currently supported: Dream-CN (utilizes Alibaba Cloud OSS). Future regions/providers may be added.

Response

code integer

Returns 0 for success, or a specific error code.

message string

Returns "success" or a descriptive error message.

data object
OSSAccessKeyId string

The Access Key ID used for authentication. Maps directly to the OSSAccessKeyId field in the Upload API request.

policy string

The Base64 encoded upload policy defining constraints like expiration and file size.

signature string

The digital signature verifying the request.

key string

The full object key (directory path + filename) where the file will be stored. Maps directly to the key field in the Upload API request.

host string

The endpoint URL of the Object Storage Service (OSS) server.

expire string

The duration (in seconds) for which this policy remains valid.

callback string

The encoded callback configuration for the server.

reqId string

The unique request identifier.

Errors

10192Illegal param
Request
cURL
curl -X POST 'https://api.newportai.com/api/file/v1/get_policy' \
-H "Authorization: Bearer {{key}}" \
-H 'Content-Type: application/json' \
-d '{
  "scene": "Dream-CN"
}'
0Successful
{
  "code": 0,
  "message": "success",
  "data": {
    "OSSAccessKeyId": "LTAI5tF1QzxoHGvEcziVACyc",
    "policy": "eyJ0leHBpcmF0aW9uIjoiMjAyNC0xMS0xOVQwODo0NDo0OC42MzZaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsNTM2ODcwOTEyMF0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJ0bXBcL2RyZWFtXC8yMDI0LTExLTE5XC81MzY5MjA3ODIwOTg5MDAyXC8iXV19",
    "signature": "G2TzrhlybemHbfFakysY4j2EI2I=",
    "key": "tmp/dream/2024-11-19/5369207820989002/f6915012-8e3a-4fb1-a1e6-64c3f4fd4797",
    "host": "https://dreamapi-oss.oss-cn-hongkong.aliyuncs.com",
    "expire": "1732005888",
    "callback": "eyJ0jYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24vanNvbiIsImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9uZXdwb3J0YWkuY29tL3ByZS1haWdjLXByaW50LTJiL2ZpbGUvdjEvY2FsbGJhY2siLCJjYWxsYmFja0JvZHkiOiJ7XCJmaWxlbmFtZVwiOiR7b2JqZWN0fSxcInNpemVcIjoke3NpemV9LFwibWltZVR5cFwiOiR7bWltZVR5cGV9LFwiaGVpZ2h0XCI6JHtpbWFnZUluZm8uaGVpZ2h0fSxcIndpZHRoXCI6JHtpbWFnZUluZm8ud2lkdGh9LFwiYnVja2V0XCI6JHtidWNrZXR9LFwiZXRhZ1wiOiR7ZXRhZ30sXCJmb3JtYXRcIjoke2ltYWdlSW5mby5mb3JtYXR9LFwiY29udGVudE1kNVwiOiR7Y29udGVudE1kNX0sXCJjbGllbnRJcFwiOiR7Y2xpZW50SXB9LFwicmVxSWRcIjoke3JlcUlkfSxcIm9wZXJhdGlvblwiOiR7b3BlcmF0aW9ufSxcImJpeklkXCI6XCJmNjkxNTAxMi04ZTNhLTRmYjEtYTFlNi02NGMzZjRmZDQ3OTdcIn0ifQ==",
    "reqId": "f6915012-8e3a-4fb1-a1e6-64c3f4fd4797"
  }
}