This document describes how to limit the speed on a single URL when calling the upload or download API.
The speed range is 819200 to 838860800 (in bit/s), that is, 100 KB/s to 100 MB/s. If a value is not within this range, 400 will be returned.
Note:For more information about the speed limits on object downloads, please see Single-URL Speed Limits.
cos.putObject({
Bucket: 'examplebucket-1250000000', /* Your bucket name. Required. */
Region: 'COS_REGION', /* Bucket region, such as `ap-beijing`. Required. */
Key: '1.jpg', /* Object key stored in the bucket (such as `1.jpg` and `a/b/test.txt`). Required. */
StorageClass: 'STANDARD',
Body: fileObject, // Upload the file object.
Headers: {
'x-cos-traffic-limit': 819200, // The speed range is 819200 to 838860800, that is 100 KB/s to 100 MB/s. If the value is not within this range, 400 will be returned.
},
onProgress: function(progressData) {
console.log(JSON.stringify(progressData));
}
}, function(err, data) {
console.log(err || data);
});
cos.getObject({
Bucket: 'examplebucket-1250000000', /* Your bucket name. Required. */
Region: 'COS_REGION', /* Bucket region, such as `ap-beijing`. Required. */
Key: '1.jpg', /* Object key stored in the bucket (such as `1.jpg` and `a/b/test.txt`). Required. */
Headers: {
'x-cos-traffic-limit': 819200, // The speed range is 819200 to 838860800, that is 100 KB/s to 100 MB/s. If the value is not within this range, 400 will be returned.
},
}, function(err, data) {
console.log(err || data.Body);
});
Was this page helpful?