首页
\
问答
\
使用android SDK将文件直接上传到存储桶中的文件夹(Upload a file directly to a folder in bucket using android SDK)
使用android SDK将文件直接上传到存储桶中的文件夹(Upload a file directly to a folder in bucket using android SDK)
我使用以下代码将文件上传到S3存储桶:
//upload code start AWSCredentials credential = new BasicAWSCredentials(AppConstants.AWS_ACCESS_KEY_ID, AppConstants.AWS_SECRET_ACCESS_ID); TransferManager manager = new TransferManager(credential); // Transfer a file to an S3 bucket. Upload upload = manager.upload("bucket_name", AppConstants.AWS_ACCESS_KEY_ID, file); while (!upload.isDone()) { Thread.sleep(200); } //upload code end
我想将它放入我的存储桶中名为“android_uploads”的目录中,但是传输管理器将所有文件上传到存储桶的根目录。
知道我怎么能做到这一点?
I am using following code to upload a file into the S3 bucket:
//upload code start AWSCredentials credential = new BasicAWSCredentials(AppConstants.AWS_ACCESS_KEY_ID, AppConstants.AWS_SECRET_ACCESS_ID); TransferManager manager = new TransferManager(credential); // Transfer a file to an S3 bucket. Upload upload = manager.upload("bucket_name", AppConstants.AWS_ACCESS_KEY_ID, file); while (!upload.isDone()) { Thread.sleep(200); } //upload code end
I want to put this into a directory named "android_uploads" inside my bucket but Transfer Manager is uploading all the files into root of the bucket.
Any idea how i can achieve this?
更新时间:2023-03-21 15:03
最满意答案
您对upload()的调用不正确。 应该是这样的:
Upload upload = manager.upload("bucket_name", "android_uploads/" + fileName, file);
Your call to upload() is incorrect. It should be like:
Upload upload = manager.upload("bucket_name", "android_uploads/" + fileName, file);
相关问答
更多-
TCP/IP模型是一个________。[2022-12-11]
a -
下列中不属于面向对象的编程语言的是?[2023-02-05]
a -
您可以按照以下步骤使用您的文件夹 1)您需要先使用以下代码获取您的folderID BoxAndroidFolder folder = data.getParcelableExtra(FolderPickerActivity.EXTRA_BOX_ANDROID_FOLDER); data * - 您的OnActivityResulr意图类型数据 2) folder.getid()将其保存为字符串变量3)将此id传递给 BoxFileUploadRequestObje ...
-
您可以通过使用HttpServletRequest .getInputStream()将输入流保存到数据成员然后将其传递给S3 SDK来获取InputStream: Execute one of the AmazonS3Client.putObject overloads depending on whether you are uploading data from a file, or a stream. 来自亚马逊S3 。 上传成功完成/出错后,您可以向用户返回相关响应。 如果您需要帮助,请告诉我。 ...
-
您可以在config/filesystems.php创建新的存储光盘: 'public_uploads' => [ 'driver' => 'local', 'root' => public_path() . '/uploads', ], 并存储这样的文件: if(!Storage::disk('public_uploads')->put($path, $file_content)) { return false; } You can create a new storage ...
-
使用android SDK将文件直接上传到存储桶中的文件夹(Upload a file directly to a folder in bucket using android SDK)[2023-03-21]
您对upload()的调用不正确。 应该是这样的: Upload upload = manager.upload("bucket_name", "android_uploads/" + fileName, file); Your call to upload() is incorrect. It should be like: Upload upload = manager.upload("bucket_name", "android_uploads/" + fileName, file); -
AWS Mobile SDK for Android v2.2.17今天发布。 此版本增加了对Amazon S3传输加速,跨区域复制和列表对象v2的支持。 有关更多信息,请参阅http://aws.amazon.com/releasenotes/5606404750751710 。 将SDK升级到最新版本后,上述代码将起作用。 AWS Mobile SDK for Android v2.2.17 is released today. This release adds support for Amazon ...
-
将文件直接上传到文件夹(upload files directly to folder)[2023-03-17]
不,它不正确。 你必须试试这个: FileUpload1.SaveAs(Server.MapPath("File//" + filename)); No, its incorrect. You have to try this: FileUpload1.SaveAs(Server.MapPath("File//" + filename)); -
如何使用公共权限将Android文件上传到S3存储桶(How to upload an Android file to S3 bucket with public permission)[2023-01-01]
要在默认情况下公开存储桶中的所有对象,请查看此问题或此问题的答案。 要在通过Android上传每个文件时为每个文件指定公共访问权限,请在PutObjectRequest上设置ACL,如下所示: PutObjectRequest putObjectRequest = new PutObjectRequest() .withCannedAcl(CannedAccessControlList.PublicRead) 看起来您现在可以使用TransferUtility在一步中设置ACL: https : ... -
使用AWS iOS SDKv2将文件上传到存储桶下的子文件夹(Upload file to sub folder under bucket with AWS iOS SDKv2)[2022-12-03]
子文件夹在S3中并不存在。 只需定义一个包含斜线的键,斜线之间的部分将在Web控制台中用斜杠表示 。 即使你会看到文件夹,但它只是一个包含斜线的关键名称。 所以在这里你想要做的是让你的密钥包含完整的目标路径。 Subfolders don't really exist in S3. Just define a key containing slashes and the parts between the slashes will be represented with slashes in the web ...