ceph rgw s3 java sdk 上传大文件分批的方法
Using the AWS Java SDK for Multipart Upload (High-Level API)
The AWS SDK for Java exposes a high-level API that simplifies multipart upload (seeUploading Objects Using Multipart Upload API). You can upload data from a file or a stream. You can also set advanced options, such as the part size you want to use for the multipart upload, or the number of threads you want to use when uploading the parts concurrently. You can also set optional object properties, the storage class, or ACL. You use the PutObjectRequest
and the TransferManagerConfiguration
classes to set these advanced options. The TransferManager
class of the Java API provides the high-level API for you to upload data.
When possible, TransferManager
attempts to use multiple threads to upload multiple parts of a single upload at once. When dealing with large content sizes and high bandwidth, this can have a significant increase on throughput.
In addition to file upload functionality, the TransferManager
class provides a method for you to abort multipart upload in progress. You must provide a Date
value, and then the API aborts all the multipart uploads that were initiated before the specified date.
Upload a File
The following tasks guide you through using the high-level Java classes to upload a file. The API provides several variations, called overloads, of the upload
method to easily upload your data.
High-Level API File Uploading Process
1 |
Create an instance of the |
2 |
Execute one of the |
The following Java code example demonstrates the preceding tasks.
Example
The following Java code example uploads a file to an Amazon S3 bucket. For instructions on how to create and test a working sample, see Testing the Java Code Examples.
import java.io.File; import com.amazonaws.AmazonClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.Upload; public class UploadObjectMultipartUploadUsingHighLevelAPI { public static void main(String[] args) throws Exception {
String existingBucketName = "*** Provide existing bucket name ***";
String keyName = "*** Provide object key ***";
String filePath = "*** Path to and name of the file to upload ***"; TransferManager tm = new TransferManager(new ProfileCredentialsProvider());
System.out.println("Hello");
// TransferManager processes all transfers asynchronously,
// so this call will return immediately.
Upload upload = tm.upload(
existingBucketName, keyName, new File(filePath));
System.out.println("Hello2"); try {
// Or you can block and wait for the upload to finish
upload.waitForCompletion();
System.out.println("Upload complete.");
} catch (AmazonClientException amazonClientException) {
System.out.println("Unable to upload file, upload was aborted.");
amazonClientException.printStackTrace();
}
}
}
http://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileJava.html
ceph rgw s3 java sdk 上传大文件分批的方法的更多相关文章
- 【Web应用】JAVA网络上传大文件报500错误
问题描述 当通过 JAVA 网站上传大文件,会报 500 错误. 问题分析 因为 Azure 的 Java 网站都是基于 IIS 转发的,所以我们需要关注 IIS 的文件上传限制以及 requestT ...
- 【转】Windows2008上传大文件的解决方法(iis7解决上传大容量文件)
2008上传大文件的解决方法:http://wenku.it168.com/d_000091739.shtml 2003上传大文件的解决方法:http://tech.v01.cn/windowsxit ...
- .net core IIS/Kestrel上传大文件的解决方法
大文件,就是内容的大小超过了一定数量的文件,比如1个GB的文件. 站点一般会限制上传文件的大小,如果超过了一定限制,则会报错误. 在处理大文件上传的方式上,IIS代理和Kestrel宿主服务器的处理方 ...
- java上传大文件解决方案
需求:项目要支持大文件上传功能,经过讨论,初步将文件上传大小控制在10G内,因此自己需要在项目中进行文件上传部分的调整和配置,自己将大小都以10G来进行限制. 第一步: 前端修改 由于项目使用的是BJ ...
- JS上传大文件的解决方案
最近遇见一个需要上传百兆大文件的需求,调研了七牛和腾讯云的切片分段上传功能,因此在此整理前端大文件上传相关功能的实现. 在某些业务中,大文件上传是一个比较重要的交互场景,如上传入库比较大的Excel表 ...
- vue上传大文件的解决方案
众所皆知,web上传大文件,一直是一个痛.上传文件大小限制,页面响应时间超时.这些都是web开发所必须直面的. 本文给出的解决方案是:前端实现数据流分片长传,后面接收完毕后合并文件的思路. 实现文件夹 ...
- Web上传大文件的解决方案
需求:项目要支持大文件上传功能,经过讨论,初步将文件上传大小控制在500M内,因此自己需要在项目中进行文件上传部分的调整和配置,自己将大小都以501M来进行限制. 第一步: 前端修改 由于项目使用的是 ...
- WEB上传大文件
众所皆知,web上传大文件,一直是一个痛.上传文件大小限制,页面响应时间超时.这些都是web开发所必须直面的. 本文给出的解决方案是:前端实现数据流分片长传,后面接收完毕后合并文件的思路.下面贴出简易 ...
- web上传大文件(>4G)有什么解决方案?
众所皆知,web上传大文件,一直是一个痛.上传文件大小限制,页面响应时间超时.这些都是web开发所必须直面的. 本文给出的解决方案是:前端实现数据流分片长传,后面接收完毕后合并文件的思路. 实现文件夹 ...
随机推荐
- Android Studio关于SVN的相关配置及从SVN检出项目
一.安装配置: 如图,安装时必须自定义选择 command line 否则不会安装的 安装完成后,打开 IDE 的 setting 配置面板: 如上图路径 Version Control 下的 Sub ...
- iOS---友盟推送遇到的坑
生产证书无效 很有可能 是你的证书上传的不对 开发证书 对应我们测试环境的推送P12文件 生产证书 对应我们线上环境的推送P12文件 device Token 无效 有可能是你的证书不对 ...
- 详解tintColor属性
tintColor属性是iOS7之后新加的一个属性,这个属性定义了一个非默认的着色颜色值,其值的设置会影响到以视图为根视图的整个视图层次结构.它主要是改变控件的颜色,以获取一些有意思的视觉效果. ti ...
- iOS Swift-注释与分号
iOS Swift-注释与分号 注释 注释是每门语言都存在的一种解释方式,Swift的注释与C语言的注释非常相似,单行注释采用//. //这是一个注释 在Swift中也可以使用多行注释,起始标记使用( ...
- VirtualBox + vagrant
VirtualBox 虚拟机不必多说 vagrant 是ruby编写的VirtualBox的命令行镜像管理工具 1 先安装VirtualBox 然后 安装 vageant 下载地址 googl ...
- apache ab测试命令详解
这篇文章主要介绍了apache性能测试工具ab使用详解,需要的朋友可以参考下 网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环.只有让服务器处在高压情况下,才能真正体现出软件.硬件等各种 ...
- vi编辑器怎么设置tab缩进
首先,在命令中输入vim ~/.vimrc 按i进入编辑模式,输入set tabstop=4 按Esc进入命令模式,输入:wq保存退出即可.
- java实现批量下载百度图片搜索到的图片
就是写的个小程序,用于记录一下,方便后续查看,首先感谢下面这个博客,从这篇文章衍生的吧,大家可以学习下: http://www.cnblogs.com/lichenwei/p/4610298.html ...
- WPF RichTextbox
WPFTextBoxAutoComplete AvalonEdit WPF SyntaxHighlightBox WinForm 下的 Fast Colored TextBox for Synta ...
- 浅谈Java中的equals和==
浅谈Java中的equals和== 在初学Java时,可能会经常碰到下面的代码: String str1 = new String("hello"); String str2 = ...