使用 Shrine 在文件夹之间移动 AWS S3 Bucket 上的文件
Move file on AWS S3 Bucket between folders using Shrine
Shrine 是否支持 copy/move S3 存储桶中文件夹之间的文件?
例如,我将一个文件上传到名为 cache
的文件夹中,如果一切正常,我会将该文件移动到 store
文件夹中并清除缓存(立即或使用后台任务)。
cache
和store
是不同的神社店(虽然属于同一个桶)。
Shrine 在上传已上传到 S3 的文件时自动执行复制请求。
Shrine.storages = {
cache: Shrine::Storage::S3.new(...),
store: Shrine::Storage::S3.new(...),
}
cached_file = Shrine.upload(file, :cache) # performs a `put_object` operation
stored_file = Shrine.upload(cached_file, :store) # performs a `copy_object` operation
因此,在附件流程中,当 Shrine "promotes" 将缓存文件永久存储时,S3 存储内部会发出复制请求。
由于S3不支持移动对象,复制后直接删除缓存文件即可。
Shrine 是否支持 copy/move S3 存储桶中文件夹之间的文件?
例如,我将一个文件上传到名为 cache
的文件夹中,如果一切正常,我会将该文件移动到 store
文件夹中并清除缓存(立即或使用后台任务)。
cache
和store
是不同的神社店(虽然属于同一个桶)。
Shrine 在上传已上传到 S3 的文件时自动执行复制请求。
Shrine.storages = {
cache: Shrine::Storage::S3.new(...),
store: Shrine::Storage::S3.new(...),
}
cached_file = Shrine.upload(file, :cache) # performs a `put_object` operation
stored_file = Shrine.upload(cached_file, :store) # performs a `copy_object` operation
因此,在附件流程中,当 Shrine "promotes" 将缓存文件永久存储时,S3 存储内部会发出复制请求。
由于S3不支持移动对象,复制后直接删除缓存文件即可。