Package com.google.appengine.api.files

Examples of com.google.appengine.api.files.FileWriteChannel


            response.addHeader("X-AppEngine-BlobRange", blobRange);
        }
    }

    private void writeToFile(AppEngineFile file, String content) throws IOException {
        FileWriteChannel channel = service.openWriteChannel(file, true);
        try {
            channel.write(ByteBuffer.wrap(content.getBytes()));
        } finally {
            channel.closeFinally();
        }
    }
View Full Code Here


    }

    protected BlobKey writeNewBlobFile(String text) throws IOException {
        FileService fileService = FileServiceFactory.getFileService();
        AppEngineFile file = fileService.createNewBlobFile("text/plain", "uploadedText.txt");
        FileWriteChannel channel = fileService.openWriteChannel(file, true);
        try {
            channel.write(ByteBuffer.wrap(text.getBytes()));
        } finally {
            channel.closeFinally();
        }
        return fileService.getBlobKey(file);
    }
View Full Code Here

    @Before
    public void setUp() throws Exception {
        fileService = FileServiceFactory.getFileService();
        AppEngineFile file = fileService.createNewBlobFile("image/png");
        FileWriteChannel channel = fileService.openWriteChannel(file, true);
        try {
            try (ReadableByteChannel in = Channels.newChannel(getImageStream("capedwarf.png"))) {
                copy(in, channel);
            }
        } finally {
            channel.closeFinally();
        }

        blobKey = fileService.getBlobKey(file);
    }
View Full Code Here

            entity = ds.get(key);
            log.info(entity.toString());

            FileService fs = FileServiceFactory.getFileService();
            AppEngineFile file = fs.createNewBlobFile("qwertfile");
            FileWriteChannel fwc = fs.openWriteChannel(file, false);
            try {
                log.info("b_l = " + fwc.write(ByteBuffer.wrap("qwert".getBytes())));
            } finally {
                fwc.close();
            }
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.files.FileWriteChannel

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.