You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
4 weeks ago
|
import { obj2xml } from '../utils/obj2xml';
|
||
|
|
||
|
/*
|
||
|
* postAsyncFetch
|
||
|
* @param {String} name the object key
|
||
|
* @param {String} url
|
||
|
* @param {Object} options
|
||
|
* {String} options.host
|
||
|
* {String} options.contentMD5
|
||
|
* {String} options.callback
|
||
|
* {String} options.storageClass Standard/IA/Archive
|
||
|
* {Boolean} options.ignoreSameKey default value true
|
||
|
*/
|
||
|
export async function postAsyncFetch(this: any, object, url, options: any = {}): Promise<object> {
|
||
|
options.subres = Object.assign({ asyncFetch: '' }, options.subres);
|
||
|
options.headers = options.headers || {};
|
||
|
object = this._objectName(object);
|
||
|
|
||
|
const { host = '', contentMD5 = '', callback = '', storageClass = '', ignoreSameKey = true } = options;
|
||
|
|
||
|
const paramXMLObj = {
|
||
|
AsyncFetchTaskConfiguration: {
|
||
|
Url: url,
|
||
|
Object: object,
|
||
|
Host: host,
|
||
|
ContentMD5: contentMD5,
|
||
|
Callback: callback,
|
||
|
StorageClass: storageClass,
|
||
|
IgnoreSameKey: ignoreSameKey
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const params = this._objectRequestParams('POST', '', options);
|
||
|
params.mime = 'xml';
|
||
|
params.xmlResponse = true;
|
||
|
params.successStatuses = [200];
|
||
|
params.content = obj2xml(paramXMLObj);
|
||
|
|
||
|
const result = await this.request(params);
|
||
|
|
||
|
return {
|
||
|
res: result.res,
|
||
|
status: result.status,
|
||
|
taskId: result.data.TaskId
|
||
|
};
|
||
|
}
|