从 AWS-S3 获取文件
Get file from AWS-S3
我在 S3 存储桶中有文件(PDF 和图像),我正在尝试使用
下载
bucket.getObject(params, function(err, data)
我正在获取 Uint8Array 中的数据,如何将其作为文件获取?
在该文件的 AWS 属性中:
Content-Disposition : inline
Content-Type : application/pdf
代码:
const params = {
Bucket: 'mts-test-procedure-document',
Key: 'Key'
};
bucket.getObject(params, function(err, data){
if (err) {
console.log('There was an error getting your file: ', err);
return false;
}
console.log('Successfully got file.', data);
// return true;
});
控制台:
Body: Uint8Array(94832) [37, 80, 68, 70, 45, 49, 46, 51, 13, 10, 37, 129, 150, 189, 221, 13, 10, 49, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 32, 47, 84, 121, 112, 101, 32, 47, 67, 97, 116, 97, 108, 111, 103, 13, 10, 47, 80, 97, 103, 101, 115, 32, 50, 32, 48, 32, 82, 13, 10, 47, 79, 117, 116, 108, 105, 110, 101, 115, 32, 51, 32, 48, 32, 82, 13, 10, 62, 62, 13, 10, 101, 110, 100, 111, 98, 106, 13, 10, 52, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 47, …]
ContentType: "application/pdf"
LastModified: Wed Sep 26 2018 15:34:59 GMT-0400 (Eastern Daylight Time) {}
Metadata: {}
您需要在上传文件时进行定义。
对于图像
Content-Type: "image/jpeg"
对于 jpeg 图片
对于 pdf:
Content-Type: "application/pdf"
Content-Disposition: inline;
可以在 https://s3browser.com/features-content-mime-types-editor.aspx
找到更多内容类型
我在 S3 存储桶中有文件(PDF 和图像),我正在尝试使用
下载bucket.getObject(params, function(err, data)
我正在获取 Uint8Array 中的数据,如何将其作为文件获取?
在该文件的 AWS 属性中:
Content-Disposition : inline
Content-Type : application/pdf
代码:
const params = {
Bucket: 'mts-test-procedure-document',
Key: 'Key'
};
bucket.getObject(params, function(err, data){
if (err) {
console.log('There was an error getting your file: ', err);
return false;
}
console.log('Successfully got file.', data);
// return true;
});
控制台:
Body: Uint8Array(94832) [37, 80, 68, 70, 45, 49, 46, 51, 13, 10, 37, 129, 150, 189, 221, 13, 10, 49, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 32, 47, 84, 121, 112, 101, 32, 47, 67, 97, 116, 97, 108, 111, 103, 13, 10, 47, 80, 97, 103, 101, 115, 32, 50, 32, 48, 32, 82, 13, 10, 47, 79, 117, 116, 108, 105, 110, 101, 115, 32, 51, 32, 48, 32, 82, 13, 10, 62, 62, 13, 10, 101, 110, 100, 111, 98, 106, 13, 10, 52, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 47, …]
ContentType: "application/pdf"
LastModified: Wed Sep 26 2018 15:34:59 GMT-0400 (Eastern Daylight Time) {}
Metadata: {}
您需要在上传文件时进行定义。 对于图像
Content-Type: "image/jpeg"
对于 jpeg 图片
对于 pdf:
Content-Type: "application/pdf"
Content-Disposition: inline;
可以在 https://s3browser.com/features-content-mime-types-editor.aspx
找到更多内容类型