简体   繁体   English

Amazon S3 PHP类,我可以直接将文件上传到存储桶中的文件夹吗

[英]Amazon S3 PHP Class, can I upload a file directly to a folder in a bucket

To upload file into bucket root I use next code: 要将文件上传到存储桶根目录,请使用以下代码:

$s3->putObjectFile($logFile, $bucketName,basename($logFile), S3::ACL_PUBLIC_READ);

but how to put file into some folder? 但是如何将文件放入某个文件夹?

I've tried smth like: 我试过像这样的东西:

'folderName\\'. basename($logFile)

but it just add "folderName\\" to file name and upload it in root of bucket. 但只需在文件名中添加“ folderName \\”,然后将其上传到存储桶的根目录即可。

Use forward slash: 使用正斜杠:

'forlderName/' . basename($logFile)

This article should explain why: http://docs.aws.amazon.com/AmazonS3/latest/dev/ListingKeysHierarchy.html 本文应解释原因: http : //docs.aws.amazon.com/AmazonS3/latest/dev/ListingKeysHierarchy.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM