跳至内容

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?

已提问 4 个月前80 查看次数
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

已回答 4 个月前
AWS
支持工程师
已审核 4 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

相关内容