Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon s3 ChunkedInputStream如何在Apache HttpClient 4.x内部工作?_Amazon S3_Apache Httpclient 4.x_Apache Httpcomponents_Spring Restcontroller_Spring Rest - Fatal编程技术网

Amazon s3 ChunkedInputStream如何在Apache HttpClient 4.x内部工作?

Amazon s3 ChunkedInputStream如何在Apache HttpClient 4.x内部工作?,amazon-s3,apache-httpclient-4.x,apache-httpcomponents,spring-restcontroller,spring-rest,Amazon S3,Apache Httpclient 4.x,Apache Httpcomponents,Spring Restcontroller,Spring Rest,我对apachehcapi有点陌生。我正试图从云环境中的服务器(10GB)下载巨大的文件,然后我必须上传到AmazonS3 由于文件太大,它采用了传输编码为分块和gzip格式。Cloud env既没有足够的磁盘空间将此文件存储为临时文件,也无法在内存中容纳此类文件 我主要有两个接口 ResourceDownloader { InputStream download(AbstractChannel channel); } ResourceUploader{ void upload(A

我对apachehcapi有点陌生。我正试图从云环境中的服务器
(10GB)下载巨大的文件,然后我必须上传到AmazonS3

由于文件太大,它采用了
传输编码为分块
gzip格式
。Cloud env既没有足够的磁盘空间将此文件存储为临时文件,也无法在内存中容纳此类文件

我主要有两个接口

ResourceDownloader {
  InputStream download(AbstractChannel channel);
 }

ResourceUploader{
   void upload(AbstractChannel channel, InputStream inputStream);
}
第1部分:

在使用ApacheHttpClient库时,我看到返回的http响应具有以下结构:

那么,这个响应是否意味着在完成client.execute(getMethod)调用后,整个10GB将在客户端的内存字节缓冲区中可用

还是说,只要我调用下面的读取调用,它就会从服务器上获取块? [在实际情况下,磁盘将不可用,但以下仅用于演示]

  try {
        FileOutputStream fos = (FileOutputStream) outputStream;

        if(inputStream instanceof GZIPInputStream) {
            byte[] buffer = new byte[1024];
            int len;
            while((len = inputStream.read(buffer)) != -1){
                fos.write(buffer, 0, len);
            }
            //close resources
            fos.close();
            inputStream.close();
        }

    } catch (IOException e) {
        logger.error("Exception occurred while processing file on disk", e);
    }
第二部分:

我知道如果我有足够的内容长度或完整的文件,可以进行多部分上传,但如果输入流是分块的,我们应该如何将其上传到AmazonS3

谢谢,
Dharam

除非特别指示,否则HttpClient始终流式处理请求和响应实体。

除非特别指示,否则HttpClient始终流式处理请求和响应实体

  try {
        FileOutputStream fos = (FileOutputStream) outputStream;

        if(inputStream instanceof GZIPInputStream) {
            byte[] buffer = new byte[1024];
            int len;
            while((len = inputStream.read(buffer)) != -1){
                fos.write(buffer, 0, len);
            }
            //close resources
            fos.close();
            inputStream.close();
        }

    } catch (IOException e) {
        logger.error("Exception occurred while processing file on disk", e);
    }