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

  • Home
  • SEARCH
  • 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 8724667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:52:39+00:00 2026-06-13T07:52:39+00:00

I am building a Google App Engine app that processes user input file, stores

  • 0

I am building a Google App Engine app that processes user input file, stores its model in the data-store, and offers the user to download the file in any format after processing the model, for that I need to create a download link for my processed files.

I have found something in Python but I’m unfamiliar with its workings.

  • How do I let Google App Engine have a download link that downloads something from a database?
  • google app engine python download file

I need to do it in Java. Any help is appreciated. Code that covers it is wonderful.

  • 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-13T07:52:40+00:00Added an answer on June 13, 2026 at 7:52 am

    This is jsp file

    <%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
    <%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
    
    <%
        BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    %>
    
    
    <html>
    <head>
        <%@ page
                language="java"
                contentType="text/html; charset=UTF-8"
                pageEncoding="UTF-8"
                %>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Upload Test</title>
    </head>
    <body>
    <form action="<%= blobstoreService.createUploadUrl("/upload") %>" method="post" enctype="multipart/form-data">
    <table>
        <tr>
            <p>Bir seferde maksimum 20 dosya yükleyebilirsiniz.</p>
        </tr>
        <tr>
            <td><input type="file" name="myFile" multiple="multiple" size="20" style="width: 522px;"></td>
        </tr>
        <tr>
            <td>
                <input type="submit" value="Yükle">
            </td>
        </tr>
    </table>
    </form>
    </body>
    </html> 
    

    This is corresponding servlet

    public class UploadDocument extends HttpServlet {
        private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    
        public void doPost(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException {
    
            Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
            List<BlobKey> blobKeys = blobs.get("myFile");
    
            if (blobKeys == null) {
                res.sendRedirect("/");
            } else {
    
                res.sendRedirect("/serve?blob-key=" + blobKeys.get(0).getKeyString());
            }
        }
    
    
    }
    

    This is downloading servlet

    public class ShowImage extends HttpServlet {
        private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    
        public void doGet(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException {
            doPost(req, res);
        }
    
        public void doPost(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException {
            String par = req.getParameter("name");
            if (par != null) {
                Query query = new Query("__BlobInfo__");
                query.addFilter("filename", Query.FilterOperator.EQUAL, req.getParameter("name"));
    
                DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
                PreparedQuery pq = datastore.prepare(query);
                List<Entity> entList = pq.asList(FetchOptions.Builder.withLimit(1));
                if (entList.size() > 0) {
                    BlobKey blobKey = new BlobKey(entList.get(0).getKey().getName());
                    BlobInfoFactory bi = new BlobInfoFactory();
                    String fname = bi.loadBlobInfo(blobKey).getFilename();
                    if (fname.contains(".jpg") || fname.contains(".JPG") || fname.contains(".jpeg") ||
                            fname.contains(".JPEG") || fname.contains(".png") || fname.contains(".PNG") ||
                            fname.contains(".GIF") || fname.contains(".gif") || fname.contains(".BMP") ||
                            fname.contains(".bmp")) {
                        res.setContentType("application/octet-stream");
                        res.setHeader("Content-Type", "save as filename=" + fname);
                        ImagesService imagesService = ImagesServiceFactory.getImagesService();
    
                        Image oldImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
                        Transform resize = ImagesServiceFactory.makeResize(580, 270,true);
    
                        Image newImage = imagesService.applyTransform(resize, oldImage);
    
                        byte[] newImageData = newImage.getImageData();
                        OutputStream outputStream = res.getOutputStream();
                        outputStream.write(newImageData);
                    } else {
                        res.setContentType("application/x-download");
                        res.setHeader("Content-Disposition", "attachment; filename=" + fname);
                        blobstoreService.serve(blobKey, res);
                    }
    
    
                } else {
                    res.setContentType("text/plain");
                    res.setCharacterEncoding("UTF-8");
                    res.getOutputStream().write("Bu isimde bir dosya bulunamadı".getBytes());
                }
            } else {
    
                res.setContentType("text/plain");
                res.setCharacterEncoding("UTF-8");
                res.getOutputStream().write("Lütfen parametre giriniz. Örnek: name=resim.jpg".getBytes());
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a web application on Google App Engine that requires users to
I'm building a Google App Engine web app, with a Java back end, that
I'm building a multiuser realtime application with Google App Engine (Python) that would look
I'm building a Google App Engine app using Spring 3.1 and am having a
I am building a web app with google app engine with python as well
I'm building an app on Google App Engine. I'm incredibly new to Python and
I'm building a web app that integrates with Google Drive, and am wondering if
I read the tutorial, https://developers.google.com/apps-script/articles/building-sites-app-part2 that uses spreadsheet service in Google sites. The code
I am building an application with Python 2.7 using the Google App Engine framework.
We've had some good experiences building an app on Google App Engine, this first

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.