Examples of GcsFilename


Examples of com.google.appengine.tools.cloudstorage.GcsFilename

            ByteArrayInputStream bais = new ByteArrayInputStream(BlobstoreServiceFactory.getBlobstoreService().fetchData(new BlobKey(blobKeyString), 0, BlobstoreService.MAX_BLOB_FETCH_SIZE - 1));
            IOUtils.copyStream(bais, outputStream);
            outputStream.write("_123".getBytes());
        } else {
            GcsFilename filename = new GcsFilename("GcsBucket", gsObjectName);
            GcsFileMetadata metadata = service.getMetadata(filename);
            if (metadata == null) {
                throw new IllegalStateException("Null GCS metadata: " + filename);
            }
            mimeType = metadata.getOptions().getMimeType();
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    }

    @Test
    @InSequence(1)
    public void testCreateGsObj() throws IOException {
        GcsFilename filename = new GcsFilename(bucket, OBJECT_NAME);
        GcsFileOptions option = new GcsFileOptions.Builder()
            .mimeType("text/html")
            .acl("public-read")
            .build();

        try (GcsOutputChannel writeChannel = gcsService.createOrReplace(filename, option)) {
            PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
            out.println(CONTENT);
            out.flush();

            writeChannel.waitForOutstandingWrites();
            writeChannel.write(ByteBuffer.wrap(MORE_WORDS.getBytes()));
            assertEquals(filename, writeChannel.getFilename());
        }

        assertEquals(bucket, filename.getBucketName());
        assertEquals(OBJECT_NAME, filename.getObjectName());
    }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    }

    @Test
    @InSequence(2)
    public void testReadGsObj() throws IOException {
        GcsFilename filename = new GcsFilename(bucket, OBJECT_NAME);
        String objContent;

        try (GcsInputChannel readChannel = gcsService.openReadChannel(filename, 0)) {
            BufferedReader reader = new BufferedReader(Channels.newReader(readChannel, "UTF8"));
            String line;
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    }

    @Test
    @InSequence(3)
    public void testDelGsObj() throws IOException {
        GcsFilename filename = new GcsFilename(bucket, OBJECT_NAME);
        assertTrue(gcsService.delete(filename));
    }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    }

    @Test
    @InSequence(4)
    public void testOptionsAndMetadata() throws IOException {
        GcsFilename filename = new GcsFilename(bucket, OBJECT_NAME + "4");
        GcsFileOptions option = new GcsFileOptions.Builder()
            .acl("public-read")
            .cacheControl("Cache-Control: public, max-age=3600")
            .contentEncoding("Content-Encoding: gzip")
            .contentDisposition("Content-Disposition: attachment")
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    public void testCreateGsBlobKey() throws Exception {
        final long ts = System.currentTimeMillis();
        final byte[] bytes = "FooBar".getBytes();

        GcsService service = GcsServiceFactory.createGcsService();
        GcsFilename filename = new GcsFilename("GcsBucket", String.valueOf(ts));
        GcsFileOptions options = new GcsFileOptions.Builder().mimeType(CONTENT_TYPE).build();
        try (GcsOutputChannel out = service.createOrReplace(filename, options)) {
            IOUtils.copy(Channels.newChannel(new ByteArrayInputStream(bytes)), out);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.