文件服务是否将数据作为blob值存储在使用Java的Google App Engine中 [英] Does File service stores the data as blob values in Google App Engine using Java

查看:78
本文介绍了文件服务是否将数据作为blob值存储在使用Java的Google App Engine中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的HTML表单,

 < form action =/ uploadmethod =postenctype = 多部分/格式数据 > 
< input type =filename =file/>
< input type =submitvalue =upload/>
< / form>

使用下面的代码在GAE中使用File服务将数据存储在Google应用引擎中。

  FileService fileService = FileServiceFactory.getFileService(); 
AppEngineFile file = fileService.createNewBlobFile(mime,fileName);
boolean lock = true;
byte [] b1 =新字节[BUFFER_SIZE];
int readBytes1;
FileWriteChannel writeChannel = fileService.openWriteChannel(file,lock); ((readBytes1 = is1.read(b1))!= -1){
writeChannel.write(ByteBuffer.wrap(b1,0,readBytes1));
}
writeChannel.closeFinally();

此文件服务是否将上传的文件存储为Google App引擎中的Blob值。




  • 在使用File服务之前,我直接在HTML表单中直接使用 createUploadUrl()方法存储文件作为blob值,我也可以在谷歌应用程序引擎中使用View Blob来查看blob。

  • 现在使用此文件后,只能看到文件的关键字,而不是查看Blob有谁能说出为什么发生这种情况。
  • 此处显示Apache Common File Upload。



    如何处理java gae中的html5输入多重数据


    I have a HTML form like this,

    <form action="/upload" method="post" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit"value="upload"/>
    </form>
    

    Using the File service in GAE with below code am storing the data in google app engine.

    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile(mime, fileName);
    boolean lock = true;
    byte[] b1 = new byte[BUFFER_SIZE];
    int readBytes1;
    FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);
    while ((readBytes1 = is1.read(b1)) != -1) {
    writeChannel.write(ByteBuffer.wrap(b1, 0, readBytes1));
    }
    writeChannel.closeFinally();
    

    Does this File service stores the uploaded file as Blob values in Google App engine.

    • Before using the File service i tried with createUploadUrl() method directly in HTML form which stored the files as blob values and i can view the blob too using "View Blob" in the google app engine.
    • Now after using this file am seeing only the key of the file, not the option " View Blob" can anyone say why this happens.

    解决方案

    Please refer to the link below. Here Apache Common File Upload is shown.

    How to handle html5 input multiple in java gae

    这篇关于文件服务是否将数据作为blob值存储在使用Java的Google App Engine中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆