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 8381891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:47:50+00:00 2026-06-09T16:47:50+00:00

To upload a file into my project directory which is there on the google

  • 0

To upload a file into my project directory which is there on the google appengine,I am trying to use apache streaming API and Google App Engine Virtual File System. Here is what I have been able to do till now :

    String path = request.getParameter("Data");
    PrintWriter writer = response.getWriter();
     try {
       boolean isMultipart = ServletFileUpload.isMultipartContent(request);
       if( !isMultipart ) {
           writer.println("File cannot be uploaded !");
       }
       else {
           ServletFileUpload upload = new ServletFileUpload();
           FileItemIterator iter = upload.getItemIterator(request);
           List list = null;
           while(iter.hasNext()) {
               FileItemStream item = iter.next();
               String name  = item.getFieldName();
               String fileName = item.getName();
               InputStream stream = item.openStream();
               if(item.isFormField()) {
                   // Process regular form field (input type="text|radio|checkbox|etc", select, etc).
               } else {
                   GaeVFS.setRootPath( getServletContext().getRealPath("/") );
                   FileSystemManager fsManager = GaeVFS.getManager();
                   //....NOW WHAT....

               }
           }
       }

I am stuck there in the else block. How to proceed now ? I have to write the file to a directory named uploads in my project.

  • 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-09T16:47:52+00:00Added an answer on June 9, 2026 at 4:47 pm

    GAE filesystem is read-only. There is no write access via an API. The only way to change filesystem contents is to update the app via appcfg.

    If you need to upload data and store it use Blobstore or Google Cloud Storage.

    Upload to blobstore:

    String path = request.getParameter("Data");
    PrintWriter writer = response.getWriter();
     try {
       boolean isMultipart = ServletFileUpload.isMultipartContent(request);
       if( !isMultipart ) {
           writer.println("File cannot be uploaded !");
       }
       else {
           ServletFileUpload upload = new ServletFileUpload();
           FileItemIterator iter = upload.getItemIterator(request);
           List list = null;
           while(iter.hasNext()) {
               FileItemStream item = iter.next();
               String name  = item.getFieldName();
               String fileName = item.getName();
               InputStream stream = item.openStream();
               if(item.isFormField()) {
                   // Process regular form field (input type="text|radio|checkbox|etc", select, etc).
               } else {
    
                // Get a file service
                FileService fileService = FileServiceFactory.getFileService();
    
                // Create a new Blob file with mime-type "text/plain"
                AppEngineFile file = fileService.createNewBlobFile(mimeType, filename);
    
                // Open a channel to write to it
                boolean lock = true;
                FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);
    
                // copy byte stream from request to channel
                byte[] buffer = new byte[10000];
                int len;
                while ((len = stream.read(buffer)) > 0) {
                    writeChannel.write(ByteBuffer.wrap(buffer, 0, len));
                }
    
                writeChannel.closeFinally();
    
                // here your data is saved to blobstore
                // you should now save a blobstore key somewhere (=to a datastore)
                // so that you can find it next time
                String blobKey = fileService.getBlobKey(file).getKeyString();
    
               }
           }
       }
    

    Serving a blob:

    public class BlobServlet extends HttpServlet {
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String blobParameter = request.getParameter("blob-key");
        if (blobParameter == null) {
            response.sendError(404, "Missing 'blob-key' parameter.");
        }
    
        BlobKey blobKey = new BlobKey(blobParameter);
    
        response.setHeader("Cache-Control", "max-age=" + (15 * 60));   // 15 min
        BlobstoreServiceFactory.getBlobstoreService().serve(blobKey, response);
    }
    }
    

    Registering your servlet:

    <servlet>
        <servlet-name>BlobServlet</servlet-name>
        <servlet-class>com.yourpackage.BlobServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>BlobServlet</servlet-name>
        <url-pattern>/blobservet</url-pattern>
    </servlet-mapping> 
    

    Referencing blob in your JSP:

    <a src="/blobserve?<%=blobKey%>">Link to blob</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project in asp.net mvc that upload excel file into action.I am
I am trying to upload my php project into public server. I made the
I want to upload an image file into mysql database on Android Mobile Programming,
I want to upload a csv file into a sql table. Here is my
I try this command to upload a file (standard.xml) into table book the file
My testers have discovered that if you type free text into a file upload
I am trying to upload file to an sharepoint online server using webclient. Up
I was trying to upload file(s) using PrototypeJs request method but I failed. The
If there is a way to Upload file using rest via stream would there
I'm trying to upload an iPhone app binary to iTunesConnect and keep getting the

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.