diff --git a/docs/examples/get_object.md b/docs/examples/get_object.md index d56305b..accbd73 100644 --- a/docs/examples/get_object.md +++ b/docs/examples/get_object.md @@ -17,7 +17,13 @@ const config = new Config({ access_key_id: 'YOUR-ACCESS-KEY-ID', secret_access_key: 'YOUR-SECRET-ACCESS-KEY', getAxiosConfig: function(operation) { - return { responseType: 'arraybuffer' }; + return { + // The data type response can be 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream', default 'json' + responseType: 'arraybuffer', + // indicates encoding to use for decoding responses, default 'utf8' + // Note: Ignored for `responseType` of 'stream' or client-side requests + responseEncoding: 'binary', + }; }, }); @@ -41,7 +47,11 @@ import fs from 'fs'; * @return {Promise} axios response */ bucket.getObject(object_key).then((response) => { - fs.writeFile(`./${object_key}`, response.data, { flag: 'wx' }, (error) => { + fs.writeFile(`./${object_key}`, response.data, { + flag: 'wx', + // default utf8 + encoding: 'binary', + }, (error) => { console.log(error); }); }).catch((error) => { diff --git a/docs/examples/get_object_zh-CN.md b/docs/examples/get_object_zh-CN.md index 5921317..cca6c7b 100644 --- a/docs/examples/get_object_zh-CN.md +++ b/docs/examples/get_object_zh-CN.md @@ -17,7 +17,13 @@ const config = new Config({ access_key_id: 'YOUR-ACCESS-KEY-ID', secret_access_key: 'YOUR-SECRET-ACCESS-KEY', getAxiosConfig: function(operation) { - return { responseType: 'arraybuffer' }; + return { + // 表示服务器响应的数据类型,可以是 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream',默认 json + responseType: 'arraybuffer', + // 用于解码响应的编码,默认 utf8 + // Note: Ignored for `responseType` of 'stream' or client-side requests + responseEncoding: 'binary', + }; }, }); @@ -41,7 +47,11 @@ import fs from 'fs'; * @return {Promise} axios response */ bucket.getObject(object_key).then((response) => { - fs.writeFile(`./${object_key}`, response.data, { flag: 'wx' }, (error) => { + fs.writeFile(`./${object_key}`, response.data, { + flag: 'wx', + // 编码,默认 utf8 + encoding: 'binary', + }, (error) => { console.log(error); }); }).catch((error) => {