Name: mos-mss
Owner: ????
Description: mtyun MSS(Meituan Storage Service) sdk for Node.js
Created: 2018-01-12 10:33:16.0
Updated: 2018-04-12 07:27:07.0
Pushed: 2018-04-12 07:27:05.0
Homepage:
null
Size: 66
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
Other Committers
User | Email | Most Recent Commit | # Commits |
README
mss-nodejs-sdk
mtyun MSS(Meituan Storage Service) sdk for Node.js
install
install mos-mss --save
Overview
Constructs a service interface object. Each API operation is exposed as a function on service.
MSS Usage
MSS, Object Storage Service. Equal to well known Amazon S3.
Constructor Details
Constructs a service object. This object has one method for each API operation.
examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
options:
- endpoint (String) ? The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like '{service}.{region}.amazonaws.com'.
- accessKeyId (String) ? your MSS access key ID.
- accessKeySecret (String) ? your MSS secret access key.
Method Summary
Bucket Operations
- listBucket()
- createBucket(name[, options])
- deleteBucket(name[, options])
- getBucketACL(name[, options])
- putBucketACL(name, ACL[, options])
- getBucket(name[, options])
- getBucketLifecycle(name[, options])
- putBucketLifecycle(name[, options])
- deleteBucketLifecycle(name,[ options])
- getBucketPolicy(name[, options])
- putBucketPolicy(name[, options])
- getBucketCors(name[, options])
- putBucketCors(name[, options])
- deleteBucketCors(name[, options])
Object Operations
- putObject(key, file[, options])
- putStream(key, file[, options])
- multipartUpload(key, file[, options])
- closeMultipartUpload(key, uploadId)
- getParts(key, uploadId)
- getObject(key, path[, options])
- getBuffer(key[, options])
- getStream(key[, options])
- listObject([options])
- copyObject(from, to[, options])
- getMeta(key[, options])
- deleteObject(key[, options])
- deleteMultiple(keys[, options])
Bucket Operations
listBucket()
Returns a list of all buckets owned by the authenticated sender of the request.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.listBucket();
lt.then(function (res) {
console.log(res);
Parameters:
- query (Object) (defaults to: {})
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- Buckets (Array)
- Name ? (String) The name of the bucket.
- CreationDate ? (Date) Date the bucket was created.
- Owner (Object)
- DisplayName ? (String)
- ID ? (String)
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
createBucket(name[, options])
Creates a new bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.createBucket('Bucket Name');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
. Set to ``
{}``` if a request error occurs. The data object has the following properties:
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
deleteBucket(name[, options])
Deletes the bucket. All objects (including all object versions and Delete Markers) in the bucket must be deleted before the bucket itself can be deleted.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.deleteBucket('Bucket Name');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getBucketACL(name[, options])
Gets the access control policy for the bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.getBucketACL('Bucket Name');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
. Set to ``
{}``` if a request error occurs. The data object has the following properties:
- Owner (Object)
- DisplayName ? (String) Screen name of the grantee.
- ID ? (String) The canonical user ID of the grantee.
- Grants ? (Array) A list of grants.
- Grantee
- DisplayName ? (String) Screen name of the grantee.
- EmailAddress ? (String) Email address of the grantee.
- ID ? (String) The canonical user ID of the grantee.
- URI ? (String) URI of the grantee group.
- Permission ? (String) Specifies the permission given to the grantee. Possible values include:
- “FULL_CONTROL”
- “WRITE”
- “WRITE_ACP”
- “READ”
- “READ_ACP”
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
putBucketACL(name, ACl[, options])
Sets the permissions on a bucket using access control lists (ACL).
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.putBucketACL('Bucket Name', 'ACL');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
- ACL ? (String) The canned ACL to apply to the bucket. Possible values include:
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getBucket(name[, options])
This operation is useful to determine if a bucket exists and you have permission to access it.mos
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.getBucket('Bucket Name');
lt.then(function (res) {
console.log(res);
//res.code === 200 exists
Parameters:
- name (String) Bucket name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
. Set to ``
{}``` if a request error occurs.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getBucketLifecycle(name[, options])
Get the bucket object lifecycle.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.getBucketLifecycle('Bucket');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:
- Rule ? (Array
- error (Object) ? the error object returned from the request. Set to
null
if the request is successful.
putBucketLifecycle(name[, options])
Set the bucket object lifecycle.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.putBucketLifecycle('Bucket', {
lifecycleConfig: {
Rule: [
{
Expiration: {
Days: 30
},
ID: 'STRING_VALUE',
Filter: {
Prefix: ''
}
}
]
}
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
- options (Object)
- lifecycleConfiguration ? (map)
- Rule ? required ? (Array
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
deleteBucketLifecycle(name[, options])
Deletes the lifecycle configuration from the bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.deleteBucketLifecycle('Bucket');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getBucketPolicy(name[, options])
Returns the policy of a specified bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.getBucketPolicy('test-bucket');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:
- Policy ? (String) The bucket policy as a JSON document.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
putBucketPolicy(name[, options])
Replaces a policy on a bucket. If the bucket already has a policy, the one in this request completely replaces it.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.putBucketPolicy('test-bucket', {
policy: {
"Version":"2012-10-17",
"Statement":[
// refer ?????
{
"Sid":"",
"Effect":"Allow",
"Principal": {"AWS": "*"},
"Action":["s3:PutObject", "s3:PutObjectAcl"],
"Resource":["arn:aws:s3:::examplebucket/*"]
},
// refer ????
{
"Sid":"",
"Effect":"Allow",
"Principal":{"AWS": "*"},
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"],
"Condition":{
"StringLike":{"aws:Referer":["http://www.example.com/*", "http://example.com/*", ""]}
}
},
{
"Sid":"Allow get requests without referrer",
"Effect":"Deny",
"Principal":{"AWS": "*"},
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"],
"Condition":{
"StringNotLike":{"aws:Referer":["http://www.example.com/*", "http://example.com/*", ""]}
}
}
]
}
lt.then(function (res) {
console.log(res);
Parameters:
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getBucketCors(name[, options])
Returns the cors configuration for the bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.getBucketCors('Bucket');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:
- CORSRule ? (Array
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
putBucketCors(name[, options])
Sets the cors configuration for a bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.putBucketCors('Bucket', {
CORSConfiguration: {
CORSRule: [
{
AllowedMethod: [
'GET',
/* more items */
],
AllowedOrigin: [
'http://www.example1.com',
'http://www.example2.com',
/* more items */
],
AllowedHeader: [
'*',
/* more items */
],
MaxAgeSeconds: 0
},
/* more items */
]
}
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
- options (Object)
- CorsConfiguration ? (map)
- CORSRule ? required ? (Array
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) - the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
deleteBucketCors(name[, options])
Deletes the cors configuration information set for the bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>'
result = client.deleteBucketCors('Bucket');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) Bucket name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) - the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
Object Operations
putObject(key, file[, options])
Adds an object to a bucket.
Examples:
ile: String
MSS = require('mos-mss');
path = require('path');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
filePath = path.join(__dirname, './test.json');
result = client.putObject('ObjectKey', filePath);
lt.then(function (res) {
console.log(res);
ile: Buffer
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.putObject('ObjectKey', new Buffer('test'));
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
- file (String|Buffer|ReadStream) object local path, content buffer or ReadStream content.
- options (Object)
- headers (Object) extra headers.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- ETag ? (String) An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
putStream(key, file[, options])
Adds an object to a bucket.
Examples:
MSS = require('mos-mss');
path = require('path');
fs = require('fs');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
filePath = path.join(__dirname, './test.json');
stream = fs.createReadStream(filePath);
result = client.putStream('ObjectKey', stream);
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
- file (ReadStream) ReadStream content.
- options (Object)
- headers (Object) extra headers.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- ETag ? (String) An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
multipartUpload(key, file[, options])
Upload file with MSS multipart.
Examples:
iecewise upload
MSS = require('mos-mss');
path = require('path');
fs = require('fs');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
write = function (data) {
return fs.writeFileSync(path.join(__dirname, './data/checkpoint.txt'), data);
result = client.multipartUpload('ObjectKey', path.join(__dirname, './img/test-big.json'), {
progress: function (p, checkpoint) {
write(JSON.stringify(checkpoint));
console.log('Progress: ' + p);
}
lt.then(function (res) {
console.log(res);
reakpoint upload
MSS = require('mos-mss');
path = require('path');
fs = require('fs');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
read = function () {
return fs.readFileSync(path.join(__dirname, './data/checkpoint.txt'), 'utf-8');
checkpoint = JSON.parse(read());
object = client.multipartUpload('Bucket', path.join(__dirname, './data/test-big.json'), {
checkpoint: checkpoint,
progress: function (p, checkpoint) {
console.log('Progress: ' + p, checkpoint);
}
ct.then(function (data) {
console.log(data);
Parameters:
- key (String) ? object name.
- file (String) object local path
- options (Object)
- partSize (Number) ? the suggested size for each part.
- checkpoint (Object) ? the checkpoint to resume upload.
- headers (Object) extra headers.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- ETag (String) ? An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL.
- Location (String)
- Bucket (String)
- Key (String)
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
closeMultipartUpload(key, uploadId)
Abort a multipart upload for object.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.closeMultipartUpload('Bucket', 'UploadId');
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
- uploadId (String) the upload id
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getParts(key, uploadId)
a list of parts that has been uploaded.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.getParts('Bucket', 'UploadId');
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
- uploadId (String) the upload id
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getObject(key, path[, options])
Retrieves objects from mos S3.
Examples:
MSS = require('mos-mss');
path = require('path');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.getObject('test.json', path.join(__dirname, './data/test.json'));
lt.then(function (data) {
console.log(data);
Parameters:
- key (String) ? object name.
- path (String) - object local path.
- options (Object)
- headers (Object) extra headers.
- query (Object)
- response-content-type (String) - Sets the Content-Type header of the response.
- response-content-language (String) - Sets the Content-Language header of the response.
- response-expires (String) - Sets the Expires header of the response.
- response-cache-control (String) - Sets the Cache-Control header of the response.
- response-content-disposition (String) - Sets the Content-Disposition header of the response.
- response-content-encoding (String) - Sets the Content-Encoding header of the response.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
`.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getBuffer(key[, options])
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.getBuffer('test');
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
- options (Object)
- headers (Object) extra headers.
- query (Object)
- response-content-type (String) - Sets the Content-Type header of the response.
- response-content-language (String) - Sets the Content-Language header of the response.
- response-expires (String) - Sets the Expires header of the response.
- response-cache-control (String) - Sets the Cache-Control header of the response.
- response-content-disposition (String) - Sets the Content-Disposition header of the response.
- response-content-encoding (String) - Sets the Content-Encoding header of the response.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- content (String) ? the data.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getStream(key[, options])
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
writeStream = fs.createWriteStream(path.join(__dirname, './data/test.json'));
result = client.getStream('ObjectKey');
lt.then(function (data) {
data.stream.pipe(writeStream);
data.stream.on('end', function () {
console.log('success');
});
data.stream.on('error', function (err) {
console.log('fail', err);
});
Parameters:
- key (String) ? object name.
- options (Object)
- headers (Object) extra headers.
- query (Object)
- response-content-type (String) - Sets the Content-Type header of the response.
- response-content-language (String) - Sets the Content-Language header of the response.
- response-expires (String) - Sets the Expires header of the response.
- response-cache-control (String) - Sets the Cache-Control header of the response.
- response-content-disposition (String) - Sets the Content-Disposition header of the response.
- response-content-encoding (String) - Sets the Content-Encoding header of the response.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
listObject([options])
Returns all of the objects in a bucket.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.listObject();
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
- options (Object)
- query (Object) query object, see the api list.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- Contents (Array) the list of object.
- Key (String) ? object name on mss.
- Etag (String) ? object etag.
- LastModified (String) ? object last modified GMT date.
- Size (Number) ? object size.
- StorageClass (String) ? storage class type.
- Owner (Object) ? object owner, including ID and DisplayName.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
copyObject(from, to[, options])
Creates a copy of an object that is already stored in mss S3.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.copyObject(?from?, 'to');
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- Etag (String) ? object etag.
- LastModified (String) ? object last modified GMT date. - error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
getMeta(key[, options])
Retrieves objects meta from mos S3.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.getMeta('ObjectKey');
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs. The data object has the following properties:
- Etag (String) ? object etag.
- LastModified (String) ? object last modified GMT date.
- ContentType (String) ? content-type.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
deleteObject(key[, options])
Deletes an object.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.deleteObject('ObjectKey');
lt.then(function (res) {
console.log(res);
Parameters:
- key (String) ? object name.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
deleteMultiple(keys[, options])
Deletes objects by query.
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.deleteMultiple('array');
lt.then(function (res) {
console.log(res);
Parameters:
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (Object) ? the de-serialized data returned from the request. The default is
`{}
.
Set to ``
{}``` if a request error occurs.
- error (Object) ? the error object returned from the request. Set to
`null
` if the request is successful.
signatureUrl(name[, options])
Examples:
MSS = require('mos-mss');
client = new MSS({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: 'Bucket'
result = client.signatureUrl('ObjectKey');
lt.then(function (res) {
console.log(res);
Parameters:
- name (String) ? object name.
- options (Object)
- headers (Object) extra headers.
- query (Object)
- response-content-type (String) - Sets the Content-Type header of the response.
- response-content-language (String) - Sets the Content-Language header of the response.
- response-expires (String) - Sets the Expires header of the response.
- response-cache-control (String) - Sets the Cache-Control header of the response.
- response-content-disposition (String) - Sets the Content-Disposition header of the response.
- response-content-encoding (String) - Sets the Content-Encoding header of the response.
Return:
- res (Object)
- code (Number) ? the code number returned from the request. The request is successful when the number is 200.
- data (String) ? object signature url.
License
MIT