跳到主要内容

上传

获取资源上传地址

调用该接口会返回一个resourceId以及上传图片请求所需的putUrlheaders。需要用户再发起一个PUT请求上传实际图片。

  • 请求示例:

    {"expireSec": 3600}

    返回结果:

    {
    "resourceId": "0b00e7f2-5ea8-4976-8b5e-cf0a3fb2cd5d",
    "putUrl": "http://tams-resource.oss-cn-hongkong.aliyuncs.com/temp%2F2023-08-22%2F0b00e7f2-5ea8-4976-8b5e-cf0a3fb2cd5d?Expires=1692675612&OSSAccessKeyId=LTAI5tBbAjwxqXDiu1tuYuke&Signature=P%2FpF7p%2BvRXTWtkg2Zz5aJAAVDjA%3D",
    "headers": {
    "Content-Type": "application/octet-stream",
    "X-Oss-Callback": "eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vZGV2LXRhbXMudGVuc29yLmFydC9yZXNvdXJjZS91cGxvYWQvY2FsbGJhY2siLCJjYWxsYmFja0JvZHkiOiJidWNrZXQ9JHtidWNrZXR9XHUwMDI2b2JqZWN0PSR7b2JqZWN0fVx1MDAyNmV0YWc9JHtldGFnfVx1MDAyNnNpemU9JHtzaXplfVx1MDAyNm1pbWVUeXBlPSR7bWltZVR5cGV9XHUwMDI2aW1hZ2VJbmZvLmhlaWdodD0ke2ltYWdlSW5mby5oZWlnaHR9XHUwMDI2aW1hZ2VJbmZvLndpZHRoPSR7aW1hZ2VJbmZvLndpZHRofVx1MDAyNmltYWdlSW5mby5mb3JtYXQ9JHtpbWFnZUluZm8uZm9ybWF0fSJ9"
    }
    }
  • 然后再上传实际图片,请求中使用到了上面的putUrlheaders,请求成功响应后就可以使用上面的resourceId来进行后续的图生图或者其他操作

    请求示例:

    curl --location --request PUT 'http://tams-resource.oss-cn-hongkong.aliyuncs.com/temp%2F2023-08-22%2F0b00e7f2-5ea8-4976-8b5e-cf0a3fb2cd5d?Expires=1692675612&OSSAccessKeyId=LTAI5tBbAjwxqXDiu1tuYuke&Signature=P%2FpF7p%2BvRXTWtkg2Zz5aJAAVDjA%3D' \
    --header 'X-Oss-Callback: eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vZGV2LXRhbXMudGVuc29yLmFydC9yZXNvdXJjZS91cGxvYWQvY2FsbGJhY2siLCJjYWxsYmFja0JvZHkiOiJidWNrZXQ9JHtidWNrZXR9XHUwMDI2b2JqZWN0PSR7b2JqZWN0fVx1MDAyNmV0YWc9JHtldGFnfVx1MDAyNnNpemU9JHtzaXplfVx1MDAyNm1pbWVUeXBlPSR7bWltZVR5cGV9XHUwMDI2aW1hZ2VJbmZvLmhlaWdodD0ke2ltYWdlSW5mby5oZWlnaHR9XHUwMDI2aW1hZ2VJbmZvLndpZHRoPSR7aW1hZ2VJbmZvLndpZHRofVx1MDAyNmltYWdlSW5mby5mb3JtYXQ9JHtpbWFnZUluZm8uZm9ybWF0fSJ9' \
    --header 'Content-Type: application/octet-stream' \
    --data '{YourFilePath}'