Image Upload
Uploads an image to the server. Image requirements: aspect ratio must be less than 1:4 or 4:1, file size less than 10MB. Supported formats: "png", "webp", "jpeg", "jpg"
The image upload process consists of three steps:
Create Upload Link
To initiate the upload, you need to create an upload session. This will return a put_url which is used to upload your image.
curl -v -H "Content-Type: application/json" -H "Authorization: Token {your_api_key}" --data '{"scene": "vidu"}' https://api.vidu.com/tools/v2/files/uploads// This will return a response with an expiring put_url. Note the id and put_url.// example{"id": "your_resource_id","put_url": "put_url_example","expires_at": "2024-09-05T04:20:29.589251952Z"}
Upload Image Using Upload Link
Use the provided put_url to upload your image via HTTP PUT method. Make sure to specify the correct Content-Type for your image format.
In the response headers, you will find an etag. Record this etag as it is needed in the next step.
curl -v -H "Content-Type: image/png" -X PUT --data-binary '@upload.png' '{put_url_example}'// The response header will contain an etag. Make sure to note this etag.// example* upload completely sent off: 157915 bytes< HTTP/2 200< content-length: 0< date: Thu, 05 Sep 2024 03:45:20 GMT< x-amz-expiration: expiry-date="Fri, 13 Sep 2024 00:00:00 GMT", rule-id="delete-for-7-days"< x-amz-server-side-encryption: AES256< etag: "d035e206b3243107372249559495346c"
Complete Upload
Finalize the upload by sending a finish request with the recorded etag. This will provide you with the URI of the uploaded image, which can then be used as an input for creating tasks.
// Send a finish request to obtain the uploaded image URI, which can be used as an input for creating tasks.curl -X PUT -H "Content-Type: application/json" -H "Authorization: Token {your_api_key}" --data '{"etag": "etag_response"}' https://api.vidu.com/tools/v2/files/uploads/{your_resource_id}/finish// example{"uri":"ssupload:?id=your_resource_id"}