跳至內容

DataSync: wrong ContentType for CSV file in S3

0

Hello,

Mime type of file on Linux source system is application/csv. Agent connection is NFSv4. When the file is copied it has ContentType octet-stream. When copying the file manually it has ContentType text/csv.

How can I fix or override this behaviour?

已提問 1 年前檢視次數 209 次

1 個回答
0

When AWS DataSync transfers files to Amazon S3, it sometimes applies default system-defined metadata to objects, which can result in unexpected ContentType values. In your case, DataSync is applying "application/octet-stream" as the ContentType for your CSV files instead of the expected "text/csv" or "application/csv".

This behavior is a known characteristic of DataSync. When transferring files from a Linux NFS source to S3, DataSync doesn't always preserve or correctly map the MIME types from the source system to the appropriate S3 ContentType values.

You have a few options to address this:

  1. Post-transfer metadata update: After the DataSync task completes, you can use the AWS CLI or SDK to update the ContentType metadata of the transferred objects.

  2. Manual transfer with metadata: For critical files where the ContentType is important, you can use the AWS CLI with the appropriate metadata parameters. For example:

aws s3 cp yourfile.csv s3://your-bucket/path/yourfile.csv --content-type "text/csv"
  1. Custom metadata: When uploading files to S3, you can specify custom metadata including ContentType using the appropriate parameters. This approach requires manual transfer or scripting rather than using DataSync.

DataSync's primary focus is on efficiently transferring data while preserving core file attributes, but it may not always preserve all system-specific metadata like MIME types exactly as they appear on the source system. This is particularly noticeable with ContentType values in S3, where DataSync often defaults to "application/octet-stream" for many file types.

If the correct ContentType is critical for your use case, you may need to implement a post-processing step to update this metadata after the DataSync transfer completes.
Sources
Troubleshooting data verification issues - AWS DataSync
Walkthrough: Attaching POSIX permissions when uploading objects into an Amazon S3 bucket - Amazon File Cache

已回答 1 年前

AWS
支援工程師

已審閱 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。