/** * Unzips a zip a file to a specified directory, deleting the zip file after unpacking. * * @param zipFile The zip file. * @param outputDirectory The directory to unpack the contents to. * @throws IOException Any I/O errors that occur. * <p>TODO: move this to IOUtils */ public static void unzipFile( org.geoserver.platform.resource.Resource zipFile, org.geoserver.platform.resource.Resource outputDirectory) throws IOException { unzipFile(zipFile, outputDirectory, null, null, null, null, false); }
/** * Unzip a zipped dataset. * * @param storeName the name of the store to handle. * @param zipFile the zipped archive * @return null if the zip file does not point to a valid zip file, the output directory otherwise. * * @deprecated use {@link #unzipFile(File, File)} * */ public static File unpackZippedDataset(String storeName, File zipFile) throws IOException, ConfigurationException { File outputDirectory = new File(GeoserverDataDirectory.findCreateConfigDir("data"), storeName); unzipFile(zipFile, outputDirectory); return outputDirectory; }
RESTUtils.unzipFile(uploadedFile, directory );
RESTUtils.unzipFile( uploadedFile, directory, workspace, store, request, files, external);
private Resource readMosaic() throws FactoryException, IOException { // Select the zip file containing the mosaic URL mosaicZip = getClass().getResource("test-data/watertemp2.zip"); Resource zipFile = Files.asResource(URLs.urlToFile(mosaicZip)); // Creation of another zip file which is a copy of the one before Resource newZip = zipFile.parent().get("watertemp2_temp.zip"); // Copy the content of the first zip to the second IOUtils.copyStream(zipFile.in(), newZip.out(), true, true); Resource mosaic = zipFile.parent().get("mosaic"); mosaic.delete(); RESTUtils.unzipFile(newZip, mosaic); return mosaic; }
RESTUtils.unzipFile(newZip, outputDirectory);