Upload a media asset using a URL
Updated at:
Upload media assets by URL by calling an OpenAPI operation through a server-side SDK.
Usage notes
To configure environment variables, see Configure environment variables in Linux, macOS, and Windows.
Example code
You can debug this operation online in Alibaba Cloud OpenAPI Developer Portal.
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import Credential, { Config } from '@alicloud/credentials';
const Client = require('@alicloud/ice20201109').default;
// An AccessKey of an Alibaba Cloud account has permissions to access all APIs. Use a Resource Access Management (RAM) user for API access or routine O&M.
// This example shows how to store an AccessKey ID and an AccessKey secret in environment variables. For more information, see: https://help.aliyun.com/document_detail/378664.html
const cred = new Credential();
const iceClient = new Client(new $OpenApi.Config({
credential: cred,
endpoint: 'ice.cn-shanghai.aliyuncs.com'
}));
// To hard-code an AccessKey ID and an AccessKey secret, use the following code. However, do not store the AccessKey pair in your project code. Storing the AccessKey pair in your code may lead to a leak, which compromises the security of all resources in your account.
// const iceClient = new Client(new $OpenApi.Config({
// accessKeyId: '<yourAccessKeyId>',
// accessKeySecret: '<yourAccessKeySecret>',
// endpoint: 'ice.cn-shanghai.aliyuncs.com'
// }));
// Upload from a URL
iceClient.uploadMediaByURL({
uploadURLs: "https://test.aliyuncdn.com/test.mp4",
uploadTargetConfig: "{\"StorageType\":\"oss\",\"StorageLocation\":\"testbucket.oss-cn-shanghai.aliyuncs.com\"}"
}).then(function (data) {
console.log(data.body);
}, function (err) {
console.log('Error:' + err);
});Related API operations
Is this page helpful?