Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9207295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:21:24+00:00 2026-06-18T00:21:24+00:00

I tried with the file service to store the data in Google app engine

  • 0

I tried with the file service to store the data in Google app engine and i successfully uploaded it but later i noted its not storing as blob values. So i googled and got this link How do I handle multipart form data? or How do I handle file uploads to my app? provided by google.

In this document the code says like below,

 FileItemIterator iterator = upload.getItemIterator(req);
 while (iterator.hasNext()) {
 FileItemStream item = iterator.next();
 InputStream stream = item.openStream();
 if (item.isFormField()) {
 log.warning("Got a form field: " + item.getFieldName());
 } else {
 log.warning("Got an uploaded file: " + item.getFieldName() +", name = " + item.getName());

 // You now have the filename (item.getName() and the
 // contents (which you can read from stream). Here we just
 // print them back out to the servlet output stream, but you
 // will probably want to do something more interesting (for
 // example, wrap them in a Blob and commit them to the
 // datastore).

Here am not understanding how to wrap them as blob and commit them to the datastore. can anyone suggest me how to solve this. Does this way stores the file as blob values in google app engine?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:21:25+00:00Added an answer on June 18, 2026 at 12:21 am
    InputStream is = item.openStream();
    try {
       FileService fileService = FileServiceFactory.getFileService();
       AppEngineFile file = fileService.createNewBlobFile(mime, fileName);
       boolean lock = true;
       FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);
       byte[] buffer = new byte[BUFFER_SIZE];
       int readBytes;
       while ((readBytes = is.read(buffer)) != -1) {
           writeChannel.write(ByteBuffer.wrap(buffer, 0, readBytes));
       }
       writeChannel.closeFinally();
       String blobKey = fileService.getBlobKey(file).getKeyString();
    } catch (Exception e) {
       e.printStackTrace(resp.getWriter());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to listen file change event in BlackBerry base on FileExplorer example, but
I tried to upload a file to my jersey server, but there is an
I tried following the README file in Ruby 1.9.1 but I can't compile it
I tried to create a file using Oracle UTL_FILE.FOPEN command but i get this
I tried: //301 Redirect Old File Redirect 301 www.mydomain.com/subdirectory http://newurl.com but that lands me
I have tried some functions of Google drive, but I couldn't able to download
I tried to use Google Analytics in my app. I created a account, registered
I tried to create jar file using command line that I inserted into java
I tried to include a file in another directory using php. There are two
I tried to read a file in a view like this: def foo(request): f

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.