Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store a file as blob values using the file service in google cloud
    primarykey
    data
    text
    <p>With the help of using the Google document <a href="https://developers.google.com/appengine/docs/java/blobstore/overview#Writing_Files_to_the_Blobstore" rel="nofollow">Writing files to a blob store</a></p> <p>I can store the file in Google Cloud in below way,</p> <pre><code> //My servlet Class private StorageService storage = new StorageService(); FileService fileService = FileServiceFactory.getFileService(); AppEngineFile file = fileService.createNewBlobFile(mime, fileName); boolean lock = true; FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock); byte[] b1 = new byte[BUFFER_SIZE]; int readBytes1; storage.init(fileName, mime); // Calling my Java Class Here while ((readBytes1 = is1.read(b1)) != -1) { writeChannel.write(ByteBuffer.wrap(b1, 0, readBytes1)); storage.storeFile(b1, readBytes1);} writeChannel.closeFinally(); </code></pre> <p>I have a storage java class to store the data in Google cloud that is below here,</p> <pre><code>//My Storage Class public class StorageService { public static final String BUCKET_NAME = "MyBucket"; public void init(String fileName, String mime) throws Exception { GSFileOptionsBuilder builder = new GSFileOptionsBuilder().setAcl("public_read").setBucket(BUCKET_NAME).setKey(fileName).setMimeType(mime); AppEngineFile writableFile = fileService.createNewGSFile(builder.build()); boolean lock = true; writeChannel = fileService.openWriteChannel(writableFile, lock); bos = new BufferedOutputStream(Channels.newOutputStream(writeChannel)); public void storeFile(byte[] b, int readSize) throws Exception { bos.write(b,0,readSize); bos.flush(); }} </code></pre> <p>From the above reference i can store the file directly in Google cloud. But i need to store those files as blob values using the File service. </p> <p>Can anyone suggest me an idea.</p> <p>your help will be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload