zipoutputstream

Using a servlet, how do you download multiple files from a database and zip them for client download

萝らか妹 提交于 2019-12-05 08:45:06
I have a jsp/servlet web app in which the client can choose a "course" and an "assignment" via dropdown boxes, and then click a button to download all the files in the database that are listed under that course/assignment combination. The servlet code isn't quite working, as the zip file is not being sent to the browser as an attachment. I do have working code for downloading one file at a time, but something is getting stuck with this code for zipping the files. All the files in the database are actually zip files themselves, so I am trying to zip up a bunch of zip files. I didn't think this

How do you add a folder to a zip archive with ICSharpCode.SharpZipLib

痴心易碎 提交于 2019-12-05 08:17:46
I have to create two folders inside of a zip file that I create programmatically using ICSharpCode.SharZipLib.Zip . I want to: private void AddToZipStream(byte[] inputStream, ZipOutputStream zipStream, string fileName, string fileExtension) { var courseName = RemoveSpecialCharacters(fileName); var m_Bytes = inputStream; if ((m_Bytes != null) && (zipStream != null)) { var newEntry = new ZipEntry(ZipEntry.CleanName(string.Concat(courseName, fileExtension))); newEntry.DateTime = DateTime.Now; newEntry.Size = m_Bytes.Length; zipStream.PutNextEntry(newEntry); zipStream.Write(m_Bytes, 0, m_Bytes

How to create a zip archive containing google cloud storage objects within appengine java app?

无人久伴 提交于 2019-12-05 02:58:02
问题 Let's say I have 50 objects (15Mb each) stored in Google Cloud Storage. Now I need to create a zip archive containing all of them and store the resultant file back at GCS. How can I do that from within an appengine java app? 回答1: I wrote the method below which seems to be working fine. public static void zipFiles(final GcsFilename targetZipFile, final GcsFilename... filesToZip) throws IOException { Preconditions.checkArgument(targetZipFile != null); Preconditions.checkArgument(filesToZip !=

Upload ZipOutputStream to S3 without saving zip file (large) temporary to disk using AWS S3 Java

给你一囗甜甜゛ 提交于 2019-12-04 20:09:37
问题 I have a requirement to download photos (not in same directory) from S3, ZIP them and again upload to S3 using AWS S3 Java SDK. This zip file size can go in GBs. Currently I am using AWS Lambda which has a limitation of temporary storage up to 500 MB. So I don't want to save ZIP file on disk instead I want to stream ZIP file (which is being created dynamically using downloaded photos from S3) directly to S3. I need this using AWS S3 Java SDK. 回答1: The basic idea is to use streaming operations

Error opening zip file created using java

我是研究僧i 提交于 2019-12-04 13:47:10
I created a small application to read some files from the disk and zip it using java.util.zip.ZipOutputStream. It is successfully creating the zip file. But in windows when i try to open it / extract it am getting the error message like "Windows has blocked access to these files to help protect your computer". I am zipping only csv files. But if i try to unzip using the zipinputstream class from java itself, its unzipping it correctly. Can anyone throw some light on it. regards, Anoop Finally I found out the problem. It was related to the path. its really funny, but if u give the absoute path

Upload ZipOutputStream to S3 without saving zip file (large) temporary to disk using AWS S3 Java

馋奶兔 提交于 2019-12-04 04:24:40
I have a requirement to download photos (not in same directory) from S3, ZIP them and again upload to S3 using AWS S3 Java SDK. This zip file size can go in GBs. Currently I am using AWS Lambda which has a limitation of temporary storage up to 500 MB. So I don't want to save ZIP file on disk instead I want to stream ZIP file (which is being created dynamically using downloaded photos from S3) directly to S3. I need this using AWS S3 Java SDK. The basic idea is to use streaming operations. This way you won't wait till the ZIP is generated on a filesystem, but start uploading as soon, as the ZIP

How can I avoid mutable variables in Scala when using ZipInputStreams and ZipOutpuStreams?

不羁岁月 提交于 2019-12-03 23:04:16
I'm trying to read a zip file, check that it has some required files, and then write all valid files out to another zip file. The basic introduction to java.util.zip has a lot of Java-isms and I'd love to make my code more Scala-native. Specifically, I'd like to avoid the use of vars . Here's what I have: val fos = new FileOutputStream("new.zip"); val zipOut = new ZipOutputStream(new BufferedOutputStream(fos)); while (zipIn.available == 1) { val entry = zipIn.getNextEntry if (entryIsValid(entry)) { zipOut.putNewEntry(new ZipEntry("subdir/" + entry.getName()) // read data into the data Array

How to create a zip archive containing google cloud storage objects within appengine java app?

十年热恋 提交于 2019-12-03 20:04:15
Let's say I have 50 objects (15Mb each) stored in Google Cloud Storage. Now I need to create a zip archive containing all of them and store the resultant file back at GCS. How can I do that from within an appengine java app? I wrote the method below which seems to be working fine. public static void zipFiles(final GcsFilename targetZipFile, final GcsFilename... filesToZip) throws IOException { Preconditions.checkArgument(targetZipFile != null); Preconditions.checkArgument(filesToZip != null); Preconditions.checkArgument(filesToZip.length > 0); final int fetchSize = 4 * 1024 * 1024; final int

How to create compressed Zip archive using ZipOutputStream so that method getSize() of ZipEntry returns correct size?

馋奶兔 提交于 2019-12-03 15:50:44
Consider the code example that put a single file test_file.pdf into zip archive test.zip and then read this archive: import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; public class Main { public static void main(String[] args) { File infile = new File("test_file.pdf"); try ( FileInputStream fis = new FileInputStream(infile); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("test.zip")); ) { int bytesRead; byte[] buffer = new byte[1024]; ZipEntry entry = new ZipEntry("data"); entry.setSize(infile.length());

Reading from a ZipInputStream into a ByteArrayOutputStream

我与影子孤独终老i 提交于 2019-12-03 15:18:25
问题 I am trying to read a single file from a java.util.zip.ZipInputStream , and copy it into a java.io.ByteArrayOutputStream (so that I can then create a java.io.ByteArrayInputStream and hand that to a 3rd party library that will end up closing the stream, and I don't want my ZipInputStream getting closed). I'm probably missing something basic here, but I never enter the while loop here: ByteArrayOutputStream streamBuilder = new ByteArrayOutputStream(); int bytesRead; byte[] tempBuffer = new byte