AWS Transfer Family AS2发送文件时MimeType错误问题排查
解决AWS Transfer Family AS2发送文件时MIME类型不正确的问题
问题原因
AWS Transfer Family AS2发起文件传输时,不会自动读取S3对象已有的Content-Type元数据,若未显式指定,会默认使用application/octet-stream作为传输的MIME类型。
解决方法
1. 通过AWS CLI指定MIME类型
修改start-file-transfer命令,添加--metadata参数显式设置Content-Type:
aws transfer start-file-transfer --connector-id c-123 --send-file-paths "/bucket/file.edifact" --metadata '{"Content-Type": "application/edifact"}'
2. 通过Java SDK指定MIME类型
在StartFileTransferRequest构建器中添加metadata配置,传入Content-Type键值对:
client.startFileTransfer( builder -> builder .connectorId(connectorId) .sendFilePaths(bucket + "/" + key) .metadata(Map.of("Content-Type", "application/edifact")) );
验证
修改后重新发起传输,查看AS2日志中的requester-content-type字段,应显示为application/edifact。
内容的提问来源于stack exchange,提问作者lukkna
相关产品推荐
相关产品推荐

