Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/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
Java 如何从S3对象获取outputstream?_Java_Image Processing_Amazon S3_Aws Java Sdk_Apache Commons Imaging - Fatal编程技术网

Java 如何从S3对象获取outputstream?

Java 如何从S3对象获取outputstream?,java,image-processing,amazon-s3,aws-java-sdk,apache-commons-imaging,Java,Image Processing,Amazon S3,Aws Java Sdk,Apache Commons Imaging,我的目标是从S3中获取一个对象(图像),更改文件的元数据,并用已更改元数据的新文件替换它 用于更改我正在使用的元数据。我在下面编写了一个示例,该示例按照预期工作,但不处理S3 File newFile = new File("newImage2.jpg"); OutputStream os = new BufferedOutputStream(new FileOutputStream(newFile)) InputStream isNew = new BufferedInputStream(ne

我的目标是从S3中获取一个对象(图像),更改文件的元数据,并用已更改元数据的新文件替换它

用于更改我正在使用的元数据。我在下面编写了一个示例,该示例按照预期工作,但不处理S3

File newFile = new File("newImage2.jpg");
OutputStream os = new BufferedOutputStream(new FileOutputStream(newFile))
InputStream isNew = new BufferedInputStream(new FileInputStream(newFile))
InputStream is = new BufferedInputStream(new FileInputStream(new File("newImage.jpg")))
try {
            String xmpXml = "<x:xmpmeta>" +
            "\n<Lifeshare>" +
            "\n\t<Date>"+"some date"+"</Date>" +
            "\n\t<Latitude>"+"somelat"+"</Latitude>" +
            "\n\t<Longitude>"+"somelong"+"</Longitude>" +
            "\n\t<Altitude>"+"somealt"+"</Altitude>" +
            "\n\t<Z>"+"someZ"+"</Z>" +
            "\n\t<X>"+"someX"+"</X>" +
            "\n\t<Y>"+"Some y"+"</Y>" +
            "\n</Lifeshare>" +
            "\n</x:xmpmeta>";
            JpegXmpRewriter rewriter = new JpegXmpRewriter();
            rewriter.updateXmpXml(is,os, xmpXml);
            String newXmpXml = Imaging.getXmpXml(isNew, "newImage2.jpg");
            println newXmpXml
        }
finally {
   is.close()
   os.close()
}
问题

如何在使用AWS S3 SDK的S3上使用对象执行相同的操作?上面的
updateXmpXml
方法要求将
OutputStream
作为第二个参数。但是,我在AWS sdk中没有看到任何outputstream类

使用apache


输出流os=…中应该包含什么?我不想将文件保存到本地文件系统。我只想使用streams。您真的不必写入临时文件
$ exiftool newImage2.jpg | grep "Lifeshare"
Lifeshare Date                  : some date
Lifeshare Latitude              : somelat
Lifeshare Longitude             : somelong
Lifeshare Altitude              : somealt
Lifeshare Z                     : someZ
Lifeshare X                     : someX
Lifeshare Y                     : Some y
OutputStream os = new ByteArrayOutputStream();


    AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider());        
    S3Object object = s3Client.getObject(
                      new GetObjectRequest(bucketName, key));
    InputStream in= object.getObjectContent();
    IOUtils.copy(in, out);

    in.close();
    out.close();