簡體   English   中英

從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中找到

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM