Release Notes
Announcements
var demo = api.require('cosClient');
function refreshCredentail() {Obtain temporary keys secretID, secretKey, token, startDate, expirationDate via a request interface;// Concatenate in the following format and return it;return "secretID=***&secretKey=***&token=***&startDate=***&expirationDate=***";}
var demo = api.require('cosClient');demo.setupPermanentCredentail({"secretID":secretID,"secretKey":secretKey});
demo.registerTransferManger({"serviceKey":"test","useHttps":true})
var demo = api.require('cosClient');demo.registerServiceForKey({"serviceKey":"test","useHttps":true})
Parameter Name | Type | Description | Required |
serviceKey | String | COS service instance unique identifier. If not passed, the default service will be registered. | No |
appId | String | Your APPID | No |
region | String | Name of the service region. Enter the abbreviation of the COS region here, such as ap-beijing. For more information about regions, see Regions and Access Domains | No |
isPrefixURL | Boolean | - | No |
timeOut | Integer | Timeout Time | No |
serviceName | String | Base name of the service. The default value is: myqcloud.com. | No |
suffix | String | Custom domain: http://bucketname.suffix If this parameter is not specified, the bucket host is http://bucketname.**. If this parameter is specified as testsuffix, the bucket host is http://bucketname.testsuffix.**. This takes effect on the iOS end. | No |
useHttps | Boolean | Whether to use https | No |
userAgent | String | Set custom ua | No |
host | String | Custom domain, excluding "http://", takes effect on the Android client. | No |
port | Integer | Custom port, takes effect on the Android client. | No |
var demo = api.require('cosClient');demo.registerTransferManger({"serviceKey":"test","useHttps":true})
Parameter Name | Type | Description | Required |
serviceKey | String | The unique identifier of the COS service instance. If not passed, the default service will be registered. | No |
appId | String | Your APPID. APPID is the account you obtain after successfully applying for a Tencent Cloud account, automatically assigned by the system, is fixed and unique, and can be viewed in account information. The APPID of a Tencent Cloud account is an application ID that has a unique correspondence with the account ID. | No |
region | String | Name of the service region. Enter the abbreviation of the COS region here, such as ap-beijing. For more information about regions, see Regions and Access Domains | No |
isPrefixURL | Boolean | Default YES. Controls the position of the bucket name in the URL during URL concatenation. Example: When NO: https://ap-chengdu.cos.myqcloud.com/examplebucket-1250000000When YES: https://examplebucket-1250000000.cos.ap-chengdu.myqcloud.com | No |
timeOut | Integer | Timeout Time | No |
serviceName | String | Base name of the service. The default value is: myqcloud.com. | No |
suffix | String | Custom domain: http://bucketname.suffix When this parameter is not specified, the bucket host is http://bucketname.**. When this parameter is specified as testsuffix, the bucket host is http://bucketname.testsuffix.**. Takes effect on iOS. | No |
useHttps | Boolean | Whether to use https | No |
userAgent | String | Set custom ua | No |
host | String | Custom domain, excluding "http://", takes effect on the Android client. | No |
port | Integer | Custom port, takes effect on the Android client. | No |
/// Module name cosClient, use the module name to obtain the module instance.var demo = api.require('cosClient');demo.getBucketList({"serviceKey":"test"},function(ret,err){/// When err is empty, return "".if(err != ""){alert(err.data);}else{alert(ret.data);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
{"result":"success","data":{buckets = [ /// Bucket list{createDate = "2021-06-02T07:33:33Z"; /// Creation timelocation = "ap-chengdu"; /// Regionname = "examplebucket-1250000000"; /// Bucket nametype = ""; /// Bucket type}];owner = {displayName = 10000000001; /// Owner's nameid = "qcs::cam::uin/10000000001:uin/10000000001"; /// Owner ID};}}
/// Module name cosClient, use the module name to obtain the module instance.var demo = api.require('cosClient');demo.deleteBucket({"serviceKey":"test","region":"ap-chengdu","bucket":"0-appid",},function(ret,err){/// Returns "" when err is null.if(err != ""){alert(err.data);}else{alert(ret.data);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
region | String | Bucket region. | Yes |
bucket | String | Bucket name in the format of BucketName-APPID | Yes |
{"result":"success"}
{"result":"error","error":{} /// Error message}
/// Module name cosClient, use the module name to obtain the module instance.var demo = api.require('cosClient');demo.createBucket({"serviceKey":"test","name":"apicloudtest","appId":"appId","region":"ap-chengdu"},function(ret,err){/// Returns "" when err is null.if(err != ""){alert(err.data);}else{alert(ret.data);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
name | String | Bucket name does not contain APPID. | Yes |
appId | String | User AppID. | Yes |
region | String | Bucket region. | Yes |
accessControlList | String | Defines the acl attribute of the bucket. Valid values: private, public-read-write, public-read; Default value: private. | No |
readAccount | String | Grant read permission to the grantee, id="OwnerUin"; | No |
writeAccount | String | Grant write permission to the grantee. Format: id="OwnerUin"; | No |
readWriteAccount | String | Grant read-write permission to the grantee. Format: id="OwnerUin"; | No |
enableMAZ | Boolean | Whether to use multi-AZ. Default is no. | No |
{"result":"success"}
{"result":"error","error":{} /// Error message}
var demo = api.require('cosClient');demo.listBucketContent({"serviceKey":"test","bucket":"0-appid","region":"ap-chengdu"},function(ret,err){/// Returns "" when err is null.if(err != ""){alert(err.data);}else{alert(ret.data);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
region | String | Bucket region. | Yes |
bucket | String | Bucket name in the format of BucketName-APPID | Yes |
prefix | String | Prefix matching, used to specify the file prefix address to be returned. | No |
delimiter | String | The delimiter is a symbol. If the Prefix is specified, the identical paths between the Prefix and the delimiter are grouped into a category and defined as a Common Prefix, and all Common Prefixes are listed. If the Prefix is not specified, identical paths from the beginning to the delimiter are grouped and defined as a Common Prefix. | No |
marker | String | By default, entries are listed in UTF-8 binary order, with all entries starting from the marker. | No |
maxKeys | String | Maximum number of entries returned per request, default: 1000 | No |
{"result":"success","data":{"Contents":[{"ETag":"\\"c57b7cd3647561480b355a92dc2e971a\\"", // MD5 digest computed based on the object content, such as "22ca88419e2ed4721c23807c678adbe4c08a7880". Note that the value is enclosed in double quotes."Owner":{"ID":"1250000000", // Complete ID of the object owner, in the format qcs::cam::uin/[OwnerUin]:uin/[OwnerUin], such as qcs::cam::uin/100000000001:uin/100000000001, where 100000000001 is the uin"DisplayName":"1250000000" // name of the object owner},"StorageClass":"STANDARD", // Storage type is STANDARD"Key":"02_Common Syntax.pdf", // File name"LastModified":"2023-01-09T11:15:25.000Z", // Last modified time"Size":816838 // File size}],"MaxKeys":1000,"IsTruncated":"False", // whether the response entries are truncated, with values 'true' or 'false'"CommonPrefixes":[ // groups the identical paths between the Prefix and the delimiter into a category and defines them as Common Prefix{"Prefix":"1\\/" // the prefix of a single Common Prefix}],"Delimiter":"\\/", // delimiter"Name":"examplebucket-1250000000" // Name of the bucket, in the format BucketName-APPID, such as examplebucket-1250000000}}
{"result":"error","error":{} /// Error message}
var uploadTaskId;var demo = api.require('cosClient');demo.uploadObject({"serviceKey":"test","region":"ap-chengdu","bucket":"0-appid","filePath":"file://test.gif","object":"test.gif"},function(ret,err){if(err != ""){alert(err.data);}else{if(ret.result == "begin"){// At begin, obtain the taskId to cancel the task.uploadTaskId = JSON.parse(ret.data).taskId;alert(uploadTaskId);}}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
region | String | Bucket region. | Yes |
bucket | String | Bucket name in the format of BucketName-APPID | Yes |
object | String | The file name uploaded to the server-side. | Yes |
filePath | String | Local file path | Yes |
uploadId | String | No need to set during the initial file upload; must be specified when resuming the upload. | No |
storageClass | String | Object storage class | No |
trafficLimit | String | The value of the speed limit for traffic control during this object upload must be a numeric value, with the default unit being bit/s. The value of the speed limit must be within the range of 819200 - 838860800 (that is, 800 Kb/s - 800 Mb/s). If the range is exceeded, a 400 error will be returned. | No |
enableVerification | String | Whether to verify the MD5 of the file returned by COS against the locally calculated MD5 after the upload is completed. Enabled by default. If verification fails, the file will still be uploaded to COS, but an error caused by verification failure will be thrown locally. | No |
{"result":"begin","data":{"taskId":taskId, // Current task ID, which can be used to cancel the task."uploadId":uploadId // Current upload ID for resuming the upload.}}
{"result":"processing","data":{"totalBytesSent":totalBytesSent, // Current transfer progress."totalBytesExpectedToSend":totalBytesExpectedToSend // Total file size.}}
{"result":"success","data":{} // File information}
{"result":"error","error":{} /// Error message}
var demo = api.require('cosClient');// uploadTaskId is obtained from the upload interface and persisted by the business logic.demo.pauseUploadObject({"taskId":uploadTaskId});
Parameter Name | Type | Description | Required |
taskId | String | Being obtained from the upload interface, it is persisted by the business logic to be used to cancel the current task. | No |
var downloadTaskId;var demo = api.require('cosClient');demo.registerTransferManger({"serviceKey":"test","useHttps":true})demo.downloadObject({"serviceKey":"test","region":"ap-chengdu","bucket":"0-appid","localPath":"file://test.gif","object":"test.gif"},function(ret,err){if(err != ""){alert(err.data);}else{if(ret.result == "begin"){// At begin, obtain the taskId to cancel the task.downloadTaskId = JSON.parse(ret.data).taskId;alert(downloadTaskId);}}});
Parameter Name | Type | Description | Required |
serviceKey | String | The unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
region | String | Bucket region. | Yes |
bucket | String | Bucket name in the format of BucketName-APPID | Yes |
object | String | Server-side file name | Yes |
versionId | String | File version number | No |
localPath | String | Local file path | Yes |
trafficLimit | String | The value of the speed limit for traffic control during this object download must be a numeric value, with the default unit being bit/s. The configurable range is 819200 - 838860800 (equivalent to 800Kb/s - 800Mb/s). Requests exceeding this range will return a 400 error. | No |
enableVerification | String | Whether to verify the file MD5 returned by COS against the locally calculated MD5 after download completion. Enabled by default; if verification fails, a validation error will be thrown. | No |
{"result":"begin","data":{"taskId":taskId, // Current task ID, which can be used to cancel the task.}}
{"result":"processing","data":{"totalBytesDownload":totalBytesDownload, // Current transfer progress."totalBytesExpectedToDownload":totalBytesExpectedToDownload // Total file size.}}
{"result":"success","data":{} // File information}
{"result":"error","error":{} /// Error message}
var demo = api.require('cosClient');// downloadTaskId is obtained from the download interface and persisted by the service.demo.pauseDownloadObject({"taskId":downloadTaskId});
Parameter Name | Type | Description | Required |
taskId | String | Obtained from the download interface, persisted by the service, and used to cancel the current task. | No |
var demo = api.require('cosClient');demo.headObject({"serviceKey":"test","region":"ap-chengdu","bucket":"0-appid","object":"test.jpg"},function(ret,err){if(err != ""){alert(err.data);}else{alert(ret.data);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
region | String | Bucket region. | Yes |
bucket | String | Bucket name in the format of BucketName-APPID | Yes |
object | String | Server-side file name | Yes |
versionId | String | File version number | No |
{"result":"success","data":{} // File object information}
{"result":"error","error":{} /// Error message}
var demo = api.require('cosClient');demo.deleteObject({"serviceKey":"test","region":"ap-chengdu","bucket":"examplebucket-1250000000","object":"test.jpg"},function(ret,err){if(err != ""){alert(err.data);}else{alert(ret.result);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance. If not passed, the default service instance is used for network requests. | No |
region | String | Bucket region. | Yes |
bucket | String | Bucket name in the format of BucketName-APPID | Yes |
object | String | Server-side file name | Yes |
versionId | String | File version number | No |
{"result":"success",}
{"result":"error","error":{} /// Error message}
var demo = api.require('cosClient');demo.cancelAll({"serviceKey":"test"},function(ret,err){if(err != ""){alert(err.data);}else{alert(ret.result);}});
Parameter Name | Type | Description | Required |
serviceKey | String | Unique identifier of the COS service instance, canceling network requests initiated by the corresponding service instance | No |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan