编程语言/S3:修订间差异
来自康健生活
| 第425行: | 第425行: | ||
} catch (error) {}</syntaxhighlight> | } catch (error) {}</syntaxhighlight> | ||
读取的时候如果文件体积较大,可以考虑直接使用流进行处理。 | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
module.exports = class extends BaseRest { | module.exports = class extends BaseRest { | ||
async getAction() { | async getAction() { | ||
const pipe = s3.getObject({Bucket: bucket, Key: name}).createReadStream(); | const pipe = s3.getObject({Bucket: bucket, Key: name}).createReadStream(); | ||
pipe.on('error', err => { | pipe.on('error', err => { | ||