Upload media assets by URL
Updated at:
Upload media assets by URL by calling an OpenAPI operation through a server-side SDK.
Prerequisites
Ensure that the Java SDK is installed. For more information, see Install Java SDK.
Usage notes
To configure environment variables, see Configure environment variables in Linux, macOS, and Windows.
Sample code
To debug this operation online, use the Alibaba Cloud OpenAPI Developer Portal.
package com.aliyun.ice.sample;
import com.aliyun.ice20201109.Client;
import com.aliyun.ice20201109.models.*;
import com.aliyun.teaopenapi.models.Config;
public class Sample {
public static void main(String[] args) throws Exception {
// An AccessKey pair of an Alibaba Cloud account has permissions to access all APIs. For security, use a Resource Access Management (RAM) user to make API calls or perform routine O&M.
// This example shows how to store the AccessKey ID and AccessKey secret in environment variables. For more information about the configuration method, see https://help.aliyun.com/document_detail/378657.html
com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
Config config = new Config();
config.setCredential(credentialClient);
// To hard-code the AccessKey ID and AccessKey secret, use the following code. Do not store the AccessKey ID and AccessKey secret in your project code. This prevents AccessKey leaks and protects the security of all your resources.
// config.accessKeyId = <yourAccessKeyId>;
// config.accessKeySecret = <yourAccessKeySecret>;
config.endpoint = "ice.cn-shanghai.aliyuncs.com";
Client client = new Client(config);
UploadMediaByURLRequest request = new UploadMediaByURLRequest()
.setUploadURLs("https://test.com/test.mp4")
.setUploadTargetConfig("{\"StorageType\":\"oss\",\"StorageLocation\":\"out-****.oss-cn-shanghai.aliyuncs.com\"}");
UploadMediaByURLResponse response = client.uploadMediaByURL(request);
System.out.println("UploadJobs: " + response.getBody().getUploadJobs());
}
}
Related API operations
Is this page helpful?