Skip to content

Get Upload Policy

POST https://api.newportai.com/api/file/v1/get_policy

Use this API to get the required parameters for Upload API.

Many of our APIs require input of some images, audio, and video files as parameters. Usually, you can put these files on your web server or cloud storage, submit the file URL in the API, and our AI program will download the required files from these URLs.

In some cases, your file size is large, or your file download speed is slow, which will cause our AI program to fail to download the file. To solve this problem, we provide the Storage service. You can upload your files to our cloud server and use the obtained file URL as an API parameter, so that our AI program can download these files faster with more stability.

The Storage service is free, but it is only used to support our AI program. We only guarantee that these file URLs can be tried for one day.

Request Headers

  • Content-TypestringRequired
    Enum
    application/json
  • AuthorizationstringRequired
    Bearer authentication format, for example: Bearer

Request Body

  • scenestringRequired
    Upload scene. There are differences in the strategies and storage methods used in different upload scenarios.

Response

  • codeinteger
    0 success, or error code.
  • messagestring
    "success", or error msg.
  • dataobject
    accessIdstring
    Access ID
    policystring
    File upload strategy
    signaturestring
    Signature for this request
    dirstring
    Designated upload file directory
    hoststring
    OSS server host
    expirestring
    The effective time of the request, in seconds
    callbackstring
    Callback url
    reqIdstring
    The request Id

Example

Request:

zsh
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"
}'

Response:

json
{
  "code": 0,
  "message": "success",
  "data": {
    "accessId": "LTAI5tF1QzxoHGvEcziVACyc",
    "policy": "eyJ0leHBpcmF0aW9uIjoiMjAyNC0xMS0xOVQwODo0NDo0OC42MzZaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsNTM2ODcwOTEyMF0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJ0bXBcL2RyZWFtXC8yMDI0LTExLTE5XC81MzY5MjA3ODIwOTg5MDAyXC8iXV19",
    "signature": "G2TzrhlybemHbfFakysY4j2EI2I=",
    "dir": "tmp/dream/2024-11-19/5369207820989002/",
    "host": "https://dreamapi-oss.oss-cn-hongkong.aliyuncs.com",
    "expire": "1732005888",
    "callback": "eyJ0jYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24vanNvbiIsImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9uZXdwb3J0YWkuY29tL3ByZS1haWdjLXByaW50LTJiL2ZpbGUvdjEvY2FsbGJhY2siLCJjYWxsYmFja0JvZHkiOiJ7XCJmaWxlbmFtZVwiOiR7b2JqZWN0fSxcInNpemVcIjoke3NpemV9LFwibWltZVR5cFwiOiR7bWltZVR5cGV9LFwiaGVpZ2h0XCI6JHtpbWFnZUluZm8uaGVpZ2h0fSxcIndpZHRoXCI6JHtpbWFnZUluZm8ud2lkdGh9LFwiYnVja2V0XCI6JHtidWNrZXR9LFwiZXRhZ1wiOiR7ZXRhZ30sXCJmb3JtYXRcIjoke2ltYWdlSW5mby5mb3JtYXR9LFwiY29udGVudE1kNVwiOiR7Y29udGVudE1kNX0sXCJjbGllbnRJcFwiOiR7Y2xpZW50SXB9LFwicmVxSWRcIjoke3JlcUlkfSxcIm9wZXJhdGlvblwiOiR7b3BlcmF0aW9ufSxcImJpeklkXCI6XCJmNjkxNTAxMi04ZTNhLTRmYjEtYTFlNi02NGMzZjRmZDQ3OTdcIn0ifQ==",
    "reqId": "f6915012-8e3a-4fb1-a1e6-64c3f4fd4797"
  }
}