Examples of ByteSource


Examples of com.google.common.io.ByteSource

            tempFile.renameTo(file);
        }
    }

    private boolean isSame(File a, BlobData b) throws IOException {
        ByteSource supplierA = Files.asByteSource(a);
        // ByteSource supplierB = ByteStreams.asByteSource(b);

        return supplierA.contentEquals(b);
    }
View Full Code Here

Examples of com.google.common.io.ByteSource

            String path = "__default/lb/data/" + Escaping.escape(host);
            String bucket = "__services";

            String contents = gson.toJson(data);

            ByteSource bytes = ByteSource.wrap(contents.getBytes(Charsets.UTF_8));

            String contentType = "application/json";
            Map<String, String> userAttributes = null;

            storageService.getFileService().putFile(project, bucket, path, FileBlob.build(bytes), contentType,
View Full Code Here

Examples of com.google.common.io.ByteSource

    }

    public void putFile(String path, File src) throws RestClientException {
        HttpRequest request = buildPut(path);

        ByteSource entity = Files.asByteSource(src);
        setRequestContent(request, entity);

        doByteArrayRequest(request);
    }
View Full Code Here

Examples of com.google.common.io.ByteSource

            String path = "services/dns/__default/zones/" + zoneName;
            String bucket = "__services";

            String contents = gson.toJson(zoneData);

            ByteSource bytes = ByteSource.wrap(contents.getBytes(Charsets.UTF_8));

            String contentType = "application/json";
            Map<String, String> userAttributes = null;

            storageService.getFileService().ensureBucket(project, bucket);
View Full Code Here

Examples of com.google.common.io.ByteSource

                return it.hasNext();
            }

            @Override
            public InputStream nextElement() {
                ByteSource is;
                try {
                    FileRange range = it.next();
                    is = getBlob(blobStore, range.getContentKey());

                    if (to != null || from != null) {
                        long start = 0;
                        if (from != null) {
                            start = Math.max(0, from - range.getStart());

                            // Enforced by the skipping logic
                            assert start <= is.size();
                        }
                        long end = is.size();
                        if (to != null) {
                            end = Math.min(to - range.getStart(), is.size());

                            // Enforced by the skipping logic
                            assert end >= 0;
                        }

                        long length = end - start;
                        if (length <= 0) {
                            assert length == 0;
                            // Easier than worrying about hasNext
                            is = EMPTY;
                        } else {
                            is = is.slice(start, length);
                        }
                    }

                    // TODO: Open buffered stream??

                    return is.openStream();
                } catch (IOException e) {
                    throw new IllegalStateException("Error reading data", e);
                }
            }
        });
View Full Code Here

Examples of com.google.common.io.ByteSource

        return is;
    }

    public ByteSource asByteSource(final BlobStore blobStore, final Long from, final Long to) {
        return new ByteSource() {
            @Override
            public InputStream openStream() throws IOException {
                return getInputStream(blobStore, from, to);
            }
        };
View Full Code Here

Examples of juju.reattore.io.ByteSource

    /** @see Interceptor */
    public boolean process(HttpRequest req, HttpResponse resp) {
        String path = req.getPath();

        ByteSource ret;

        File serve = new File(baseDir, path);

        if (serve.isDirectory()) {
            /* Redirect if the request is incomplete. */
 
View Full Code Here

Examples of juju.reattore.io.ByteSource

          can't be found.
    */
    public ByteSource get(String req, File resolved)
        throws IOException {

        ByteSource ret;

        if ((ret = tryGet(req)) != null) {
            return ret;
        }
        else {
View Full Code Here

Examples of juju.reattore.io.ByteSource

    }

    private String getBody()
        throws IOException {

        ByteSource body = resp.getBody();
        byte[] ab = new byte[body.remaining()];

        assertEquals(body.remaining(), body.get(ab, 0, ab.length));

        return new String(ab);
    }
View Full Code Here

Examples of juju.reattore.io.ByteSource

        throws IOException {

        String req = "tests/test/juju/reattore/server/intercept/impl/testfilecache.txt";
        File f = new File(req);

        ByteSource bs = cache.get(req, f);
        String body = getBody(bs);

        assertEquals("This is testfilecache.txt", body);
        bs.dispose();
    }
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.