我需要從Amazon S3獲取Microsoft Word(.docx)文件的內容。我能夠得到該對象,但結果並不是我想要的,因爲它看起來像在記事本中打開的Word文件。我試圖讀取.txt文件,它完美的作品。我認爲這個問題是一種內容類型。來自Amazon S3的Word文件的內容類型
我想請教兩個問題:
- 是否有可能獲得該文件的內容是文件@Amazon以及如何修改我的代碼做achive呢?
- 是否可以通過格式化(顏色,粗體文本等)來獲取內容?如果是這樣,我會讚揚一些線索。
我的代碼:
public static string ReadObjectData(string keyName)
{
string responseBody = "";
//using (IAmazonS3 client = new AmazonS3Client(RegionEndpoint.USEast1))
using (IAmazonS3 client = new Amazon.S3.AmazonS3Client("key", "secretKey", Amazon.RegionEndpoint.EUCentral1))
{
GetObjectRequest request = new GetObjectRequest
{
BucketName = "bucketName",
Key = keyName
};
using (GetObjectResponse response = client.GetObject(request))
using (Stream responseStream = response.ResponseStream)
using (StreamReader reader = new StreamReader(responseStream))
{
responseBody = reader.ReadToEnd();
}
}
return responseBody;
}
在處理打開文檔的問題中沒有代碼,你能解釋你在做什麼觸發文件在記事本中打開嗎? –