是否可以将单个文件同步到s3?

use*_*956 5 amazon-s3

我想将文件系统中的单个文件同步到s3.

这是可能的还是只能同步目录?

Cod*_*ker 15

cp可用于将单个文件复制到 S3。如果文件名已存在于目标中,则将替换它:

\n
aws s3 cp local/path/to/file.js s3://bucket/path/to/file.js\n
Run Code Online (Sandbox Code Playgroud)\n

请记住,根据文档sync当自上次运行以来源文件发生了文件更改时,才会对目标进行更新:s3 sync updates any files that have a size or modified time that are different from files with the same name at the destination.但是,cp无论源文件是否已修改,都将始终对目标进行更新。

\n

参考:AWS CLI 命令参考:\xc2\xa0cp

\n


pyt*_*981 10

使用sync-directory命令的include/exclude选项:

例如,只需将/var/local/path/filename.xyz同步到S3使用:

s3 sync /var/local/path s3://bucket/path --exclude='*' --include='*/filename.xyz'
Run Code Online (Sandbox Code Playgroud)

  • 应该是: --include='filename.xyz' - 使用 */ 它还会复制子文件夹中具有相同名称的文件 (6认同)
  • 对于在 Windows 上使用 AWS CLI 的任何人,我必须使用 `"` 而不是 `'` 否则它将无法工作 (2认同)