List of usage examples for com.amazonaws.services.glacier.transfer ArchiveTransferManager download
public void download(final String vaultName, final String archiveId, final File file) throws AmazonServiceException, AmazonClientException
From source file:com.leverno.ysbos.archive.example.ArchiveDownloadHighLevel.java
License:Open Source License
public static void main(String[] args) throws IOException { AWSCredentials credentials = getCredentials(); AmazonSQSClient sqs = new AmazonSQSClient(credentials); AmazonSNSClient sns = new AmazonSNSClient(credentials); glacier = new AmazonGlacierClient(credentials); glacier.setEndpoint(Constants.endpoint); sqs.setEndpoint(Constants.endpoint); sns.setEndpoint(Constants.endpoint); try {// w ww .j ava 2 s .co m ArchiveTransferManager atm = new ArchiveTransferManager(glacier, sqs, sns); atm.download(vaultName, archiveId, new File(downloadFilePath)); } catch (Exception e) { System.err.println(e); } }
From source file:de.kopis.glacier.commands.DownloadArchiveCommand.java
License:Open Source License
public void download(final String vaultName, final String archiveId, final File targetFile) { log.info("Downloading archive " + archiveId + " from vault " + vaultName + "..."); final ArchiveTransferManager atm = new ArchiveTransferManager(client, sqs, sns); atm.download(vaultName, archiveId, targetFile); log.info("Archive downloaded to " + targetFile); }
From source file:de.kopis.glacier.GlacierArchiveDownloader.java
License:Open Source License
public void download(final URL endpointUrl, final String vaultName, final String archiveId) { System.out.println("Downloading archive " + archiveId + " from vault " + vaultName + "..."); client.setEndpoint(endpointUrl.toExternalForm()); try {//from ww w . j a va 2 s . co m final File downloadFile = File.createTempFile("glacier-", ".dl"); final ArchiveTransferManager atm = new ArchiveTransferManager(client, credentials); atm.download(vaultName, archiveId, downloadFile); System.out.println("Archive downloaded to " + downloadFile); } catch (final IOException e) { System.err.println("Can not download archive " + archiveId + " from vault " + vaultName + "."); e.printStackTrace(); } }
From source file:nl.nekoconeko.glaciercmd.GlacierClient.java
License:Open Source License
protected void downloadFile(String vault, String identifier, String filename) { ArchiveTransferManager atm = new ArchiveTransferManager(this.client, this.credentials); try {/*from w w w.j a v a 2 s. c o m*/ atm.download(vault, identifier, new File(filename)); } catch (AmazonServiceException e) { System.err.println("An error occured at Amazon AWS: " + e.getLocalizedMessage()); System.exit(1); } catch (AmazonClientException e) { System.err.println("An error occured while executing the request: " + e.getLocalizedMessage()); System.exit(1); } }
From source file:org.duraspace.glacier.AmazonDownloadRequest.java
License:Open Source License
public void actionPerformed(ActionEvent e) { if (e.getSource() == jbtDownload) { archiveId = jtfDownloadField.getText().trim(); if ((archiveId.equals(""))) { JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error", JOptionPane.ERROR_MESSAGE); } else {/*from w ww. j a v a 2s . c om*/ SwingWorker downloadWorker = new SwingWorker() { private String archiveId = jtfDownloadField.getText().trim(); @Override protected Object doInBackground() throws Exception { //Create dumb progressbar JFrame downloadFrame = new JFrame("Downloading"); { downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); dumJProgressBar.setIndeterminate(true); downloadFrame.add(dumJProgressBar, BorderLayout.NORTH); downloadFrame.setSize(300, 60); } centerDefineFrame(downloadFrame, 300, 50); String archiveId = jtfDownloadField.getText().trim(); try { String vaultName = dlVault; FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE); fd.setFile("Save Archive As..."); fd.setDirectory(System.getProperty("user.dir")); fd.setLocation(50, 50); fd.setVisible(true); String filePath = "" + fd.getDirectory() + System.getProperty("file.separator") + fd.getFile(); File outFile = new File(filePath); if (outFile != null) { downloadFrame.setTitle("Downloading " + outFile.toString()); downloadFrame.setVisible(true); ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlCredentials); atm.download(vaultName, archiveId, outFile); JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(), "Success", JOptionPane.INFORMATION_MESSAGE); downloadFrame.setVisible(false); } } catch (AmazonServiceException k) { JOptionPane.showMessageDialog(null, "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE); System.out.println("" + k); downloadFrame.setVisible(false); } catch (AmazonClientException i) { JOptionPane.showMessageDialog(null, "Client Error. Check that all fields are correct. Archive not deleted.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } catch (Exception j) { JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } return null; } }; downloadWorker.execute(); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } this.setVisible(false); dispose(); } } else if (e.getSource() == jbtBack) { this.setVisible(false); dispose(); } else { JOptionPane.showMessageDialog(this, "Please choose a valid action."); } }