Package com.amazonaws.services.s3.model

Examples of com.amazonaws.services.s3.model.S3ObjectInputStream


                                AmazonS3 client = mock(AmazonS3Client.class);
                                ObjectListing objectListing = mock(ObjectListing.class);
                                S3ObjectSummary summary = mock(S3ObjectSummary.class);
                                S3Object s3Object = mock(S3Object.class);

                                S3ObjectInputStream inputStream = mock(S3ObjectInputStream.class);

                                when(client.listObjects(anyString(), anyString())).thenReturn(objectListing);
                                when(objectListing.getObjectSummaries()).thenReturn(Arrays.asList(summary));
                                when(summary.getKey()).thenReturn("foo");
                                when(client.getObject("fakebucket", "foo")).thenReturn(s3Object);
                                when(s3Object.getObjectContent()).thenReturn(inputStream);
                                when(inputStream.read(new byte[anyInt()], anyInt(), anyByte())).thenReturn(-1);
                                when(client.listNextBatchOfObjects(any(ObjectListing.class))).thenReturn(objectListing);
                                when(objectListing.isTruncated()).thenReturn(false);
                                return client;
                            }
                        });
View Full Code Here


        this.withRegion("s3-ap-southeast-1");
        this.withKey("AAAAAAAAAAAAAAAAAAAA");
        this.withSecret("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        final S3Object object = Mockito.mock(S3Object.class);
        Mockito.doReturn(
            new S3ObjectInputStream(
                IOUtils.toInputStream("TXT"),
                new HttpGet()
            )
        ).when(object).getObjectContent();
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
View Full Code Here

    public void writesFromAmazonObjectToOutputStream() throws Exception {
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final S3Object object = Mockito.mock(S3Object.class);
        Mockito.doReturn(object).when(client)
            .getObject(Mockito.any(GetObjectRequest.class));
        final S3ObjectInputStream stream =
            Mockito.mock(S3ObjectInputStream.class);
        Mockito.doReturn(-1).when(stream).read(Mockito.any(byte[].class));
        Mockito.doReturn(stream).when(object).getObjectContent();
        MatcherAssert.assertThat(
            ResourceMocker.toString(
View Full Code Here

        final byte[] data = new byte[size];
        final Random random = new SecureRandom();
        for (int pos = 0; pos < size; ++pos) {
            data[pos] = (byte) random.nextInt();
        }
        final S3ObjectInputStream stream = new S3ObjectInputStream(
            new ByteArrayInputStream(data),
            new HttpGet()
        );
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final S3Object object = Mockito.mock(S3Object.class);
View Full Code Here

     * DefaultResource can throw when failed to read.
     * @throws Exception If there is some problem inside
     */
    @Test(expected = IOException.class)
    public void throwsWhenFailedToRead() throws Exception {
        final S3ObjectInputStream stream =
            Mockito.mock(S3ObjectInputStream.class);
        Mockito.doThrow(new IOException("oops"))
            .when(stream).read(Mockito.any(byte[].class));
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final S3Object object = Mockito.mock(S3Object.class);
View Full Code Here

        final byte[] data = new byte[size];
        final Random random = new Random();
        for (int pos = 0; pos < size; ++pos) {
            data[pos] = (byte) random.nextInt();
        }
        final S3ObjectInputStream stream = new S3ObjectInputStream(
            new ByteArrayInputStream(data),
            new HttpGet()
        );
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final S3Object object = Mockito.mock(S3Object.class);
View Full Code Here

        if (range[0] > range[1]) {
            // Make no modifications if range is invalid.
            return s3object;
        }
        try {
            S3ObjectInputStream objectContent = s3object.getObjectContent();
            InputStream adjustedRangeContents = new AdjustedRangeInputStream(objectContent, range[0], range[1]);
            s3object.setObjectContent(new S3ObjectInputStream(adjustedRangeContents, objectContent.getHttpRequest()));
            return s3object;
        } catch (IOException e) {
            throw new AmazonClientException("Error adjusting output to desired byte range: " + e.getMessage());
        }
    }
View Full Code Here

     * @return
     *      The updated object where the object content input stream contains the decrypted contents.
     */
    private S3ObjectWrapper decrypt(S3ObjectWrapper wrapper,
            ContentCryptoMaterial cekMaterial, long[] range) {
        S3ObjectInputStream objectContent = wrapper.getObjectContent();
        wrapper.setObjectContent(new S3ObjectInputStream(
                new CipherLiteInputStream(objectContent,
                    cekMaterial.getCipherLite(),
                    DEFAULT_BUFFER_SIZE),
                    objectContent.getHttpRequest()));
        return wrapper;
    }
View Full Code Here

     *      The instruction that will be used to decrypt the object data.
     * @return
     *      The updated object where the object content input stream contains the decrypted contents.
     */
    public static S3Object decryptObjectUsingInstruction(S3Object object, EncryptionInstruction instruction) {
        S3ObjectInputStream objectContent = object.getObjectContent();

        InputStream decryptedInputStream = new RepeatableCipherInputStream(objectContent, instruction.getCipherFactory());
        object.setObjectContent(new S3ObjectInputStream(decryptedInputStream, objectContent.getHttpRequest()));
        return object;
    }
View Full Code Here

        if (range == null || range[0] > range[1]) {
            // Make no modifications if range is invalid.
            return object;
        } else {
            try {
                S3ObjectInputStream objectContent = object.getObjectContent();
                InputStream adjustedRangeContents = new AdjustedRangeInputStream(objectContent, range[0], range[1]);
                object.setObjectContent(new S3ObjectInputStream(adjustedRangeContents, objectContent.getHttpRequest()));
                return object;
            } catch (IOException e) {
                throw new AmazonClientException("Error adjusting output to desired byte range: " + e.getMessage());
            }
        }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.s3.model.S3ObjectInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.