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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:41:04+00:00 2026-06-06T22:41:04+00:00

On a server hosted on google app engine, I am trying to download files

  • 0

On a server hosted on google app engine, I am trying to download files from another server, zip (using util.zip) them and upload the zip file for later download.

I have files in a folder (html and png files). The download and zip and upload is successful. I can download the desired zip, however I can not open the png files, even though I can the original ones. It says the program doesn’t support the file format. Interestingly the there are no problems with the html files in the zip.
Does anybody know what can be the problem here?

Thank you in advance.

–THE CODE–

public boolean generateZip(){
    byte[] application = new byte[1500000];
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(baos);

    //This will get the desired file names and locations from the other server
    ArrayList<String> others = getFileNames(this); 
    for(String s: others){
            URL url = new URL("http://otherserver.com/" + s);
            BufferedReader reader = null;
            try{
                                    //I need only the file names not the full directory name
                int toSub = s.lastIndexOf("/");
                String entryString = s.substring(toSub+1);
                out.putNextEntry(new ZipEntry(entryString));

                reader = new BufferedReader(new InputStreamReader(url.openStream()));   
                byte[] buffer = new byte[3000000];
                int bindex = 0;
                int b = reader.read();
                while(b != -1){
                    buffer[bindex] = (byte) b;
                    bindex++;
                    b = reader.read();
                }
                out.write(buffer,0,bindex); 
                out.closeEntry();
                reader.close();

                System.out.println(entryString + " packaged...");
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    }

    out.close();
    } catch (IOException e) {
        System.out.println("There was an error generating ZIP.");
        e.printStackTrace();
    }
            return uploadZip(baos.toByteArray());
}
  • 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-06T22:41:07+00:00Added an answer on June 6, 2026 at 10:41 pm

    Finally I found the solution. For anyone who’s interested:

    for(String s: others){
    
                URL url = new URL("http://otherserver.com" + s);
                System.out.println("Reading " + s);
                try{
                    int toSub = s.lastIndexOf("/");
                    String entryString = s.substring(toSub+1);
                    out.putNextEntry(new ZipEntry(entryString));
    
                    BufferedInputStream in = new BufferedInputStream(url.openStream());
                    ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
                    BufferedOutputStream out2 = new BufferedOutputStream(baos2);
                    int i;
                    while ((i = in.read()) != -1) {
                        out2.write(i);
                    }
                    out2.flush();
                    byte[] data = baos2.toByteArray();
                    // closing all the shits
                    out2.close();
                    in.close();
                    out.write(data,0,data.length);  
                    out.closeEntry();
    
                    System.out.println(entryString + " packaged...");
                }catch(Exception e){
                    e.printStackTrace();
                }           
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to push a self-hosted server repository to Git using Git extensions.
I create a server clone from a project hosted at code.google.com. I create a
I am testing a google app engine app. I just deployed to the hosted
I've been trying for a few days now to get Google App Engine to
I want to get xml data from google server using it's API. so, i
I'm trying to setup Microsoft reporting on a shared hosted server. I've set up
I'm using GWT (currenly working with google's eclipse plugin), and I'm trying to throw
Trying to start an app developed on Mac and hosted on Github, now trying
Currently, I have a few hundred image files, hosted in Google Drive. I wish
We have Windows Server 2008 as our Production server hosted in RackSpace environment. Following

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.