src/index.js
function (host,accessKey, secretKey, bucket, objects, opts = {}) {

    if (!objects.length) {
        return Promise.reject(new Error('nothing to delete'));
    }

    let date = utcDate();
    let content = deletePayload({objects, quiet: opts.quiet});
    let contentLength = content.length;
    let url = `http://${bucket}.${host}/?delete`;
    let authorization = authorize(accessKey, secretKey, 'POST', '', '', date, [], '');

    let headers = {
        Date: date,
        Authorization: authorization,
        'Content-Length': contentLength
    };

    return nosRequest({method: 'post', body: content, headers, uri: url})
        .then(res => {
            if(!opts.quiet) {
                if(res.DeleteResult) {
                    let {Error} = res.DeleteResult;
                    let ret = Error.map((detail) => {
                        return {
                            key: detail.Key.join(''),
                            code: detail.Code.join(''),
                            message: detail.Message.join('')
                        }
                    });
                    return {error: ret}
                } else {
                    return {};
                }
            }
            let {Deleted = [], Error = []} = res.DeleteResult;
            let deleted = Deleted.map(detail => {
                return detail.Key.join('');
            });
            let error = Error.map((detail) => {
                return {
                    key: detail.Key.join(''),
                    code: detail.Code.join(''),
                    message: detail.Message.join('')
                }
            });
            return {deleted, error};
        });
}
function (host,accessKey, secretKey, bucket, objects, opts = {}) {

    if (!objects.length) {
        return Promise.reject(new Error('nothing to delete'));
    }

    let date = utcDate();
    let content = deletePayload({objects, quiet: opts.quiet});
    let contentLength = content.length;
    let url = `http://${bucket}.${host}/?delete`;
    let authorization = authorize(accessKey, secretKey, 'POST', '', '', date, [], '');

    let headers = {
        Date: date,
        Authorization: authorization,
        'Content-Length': contentLength
    };

    return nosRequest({method: 'post', body: content, headers, uri: url})
        .then(res => {
            if(!opts.quiet) {
                if(res.DeleteResult) {
                    let {Error} = res.DeleteResult;
                    let ret = Error.map((detail) => {
                        return {
                            key: detail.Key.join(''),
                            code: detail.Code.join(''),
                            message: detail.Message.join('')
                        }
                    });
                    return {error: ret}
                } else {
                    return {};
                }
            }
            let {Deleted = [], Error = []} = res.DeleteResult;
            let deleted = Deleted.map(detail => {
                return detail.Key.join('');
            });
            let error = Error.map((detail) => {
                return {
                    key: detail.Key.join(''),
                    code: detail.Code.join(''),
                    message: detail.Message.join('')
                }
            });
            return {deleted, error};
        });
}
批量删除对象
@param {String} accessKey
@param {String} secretKey
@param {String} bucket
@param {Array} objects  要删除的对象
@param {Object} [opts]
@param {boolean} [opts.quiet]  是否安静删除