Package com.amazonaws.services.glacier.transfer

Examples of com.amazonaws.services.glacier.transfer.UploadResult


  public void upload(File file, String dst) throws AmazonServiceException,
      AmazonClientException, FileNotFoundException {
    logger.info(will("Use amazon glacier ArchiveTransferManager"
        + " to transfer file to a vault", "file", file, "vault", vault,
        "destination", dst));
    UploadResult result = transferManager.upload(vault, dst, file);
    logger.info(done("Uploading file to glacier."));
    putArchiveId(dst, result.getArchiveId());
  }
View Full Code Here


  }

  public void upload_givenFile_returnsUploadResultWithArchiveIdWhichIdentifiesTheFile()
      throws AmazonServiceException, AmazonClientException,
      FileNotFoundException {
    UploadResult uploadResult = transferManager
        .upload(null, null, createFile());

    File file = getFileInManagedDirectory();
    File fileByArchiveId = transferManager.getFile(uploadResult.getArchiveId());
    assertEquals(file.getAbsolutePath(), fileByArchiveId.getAbsolutePath());
  }
View Full Code Here

  public void download_givenUploadedFile_downloadsFileToSpecifiedOutputFile()
      throws AmazonServiceException, AmazonClientException,
      FileNotFoundException {
    File fileWithContent = createFileWithRandomContent();
    UploadResult upload = transferManager.upload(null, null, fileWithContent);

    File outputFile = createFilePath();
    transferManager.download(null, upload.getArchiveId(), outputFile);
    TUtilsTestNG.assertFileContentsEqual(outputFile, fileWithContent);
  }
View Full Code Here

  @Test(expectedExceptions = { RuntimeException.class })
  public void download_givenExistingFile_throws()
      throws AmazonServiceException, AmazonClientException,
      FileNotFoundException {
    UploadResult upload = transferManager.upload(null, null, createFile());
    transferManager.download(null, upload.getArchiveId(), createFile());
  }
View Full Code Here

  public void upload_givenPath_canGetArchiveIdWithPath()
      throws AmazonServiceException, AmazonClientException,
      FileNotFoundException {
    File file = createFile();
    String dst = "/path/dst";
    UploadResult uploadResult = mock(UploadResult.class);
    String archiveId = "archiveId";
    when(uploadResult.getArchiveId()).thenReturn(archiveId);
    when(transferManager.upload(vault, dst.toString(), file)).thenReturn(
        uploadResult);

    glacierClient.upload(file, dst);
    assertEquals(archiveId, glacierClient.getArchiveId(dst));
View Full Code Here

  public UploadResult upload(String accountId, String vaultName,
      String archiveDescription, File file) throws AmazonServiceException,
      AmazonClientException, FileNotFoundException {
    copyFileToManagedDirectory(file);
    UUID uuid = storeUuidForFile(file);
    return new UploadResult(uuid.toString());
  }
View Full Code Here

                  uw.setTitle("(" + (i + 1) + "/"
                      + uploadFileBatch.length + ")"
                      + " Uploading: " + thisFile);

                  UploadResult result = atm.upload(vaultName,
                      cleanFile, uploadFileBatch[i]);

                  uw.addToLog("Done: " + thisFile + "\n");

                  uploadedSize += uploadFileBatch[i].length();

                  int percentage = (int) (((double) uploadedSize / totalSize) * 100);

                  uw.updateProgress(percentage);

                  Writer plainOutputLog = null;
                  Writer plainOutputTxt = null;
                  Writer plainOutputCsv = null;

                  // write to file
                  if (logCheckMenuItem.isSelected()) {
                    String treeHash = TreeHashGenerator
                        .calculateTreeHash(uploadFileBatch[i]);

                    try {
                      plainOutputLog = new BufferedWriter(
                          new FileWriter(
                              getLogFilenamePath(0),
                              true));
                      plainOutputTxt = new BufferedWriter(
                          new FileWriter(
                              getLogFilenamePath(1),
                              true));
                      plainOutputCsv = new BufferedWriter(
                          new FileWriter(
                              getLogFilenamePath(2),
                              true));

                    } catch (IOException ex) {
                      JOptionPane.showMessageDialog(null,
                          LOG_CREATION_ERROR,
                          "IO Error",
                          JOptionPane.ERROR_MESSAGE);
                      uw.dispose();
                      System.exit(1);
                    }

                    try {

                      Date d = new Date();

                      String thisResult = result
                          .getArchiveId();

                      plainOutputLog
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputLog
                          .write(" | ArchiveID: "
                              + thisResult + " ");
                      plainOutputLog
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputLog.write(" | File: "
                          + thisFile + " ");
                      plainOutputLog.write(" | Bytes: "
                          + fileLength + " ");
                      plainOutputLog.write(" | Vault: "
                          + vaultName + " ");
                      plainOutputLog
                          .write(" | Location: "
                              + locationUpped
                              + " ");
                      plainOutputLog.write(" | Date: "
                          + d.toString() + " ");
                      plainOutputLog.write(" | Hash: "
                          + treeHash + " ");
                      plainOutputLog
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputLog.close();

                      plainOutputTxt
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputTxt
                          .write(" | ArchiveID: "
                              + thisResult + " ");
                      plainOutputTxt
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputTxt.write(" | File: "
                          + thisFile + " ");
                      plainOutputTxt.write(" | Bytes: "
                          + fileLength + " ");
                      plainOutputTxt.write(" | Vault: "
                          + vaultName + " ");
                      plainOutputTxt
                          .write(" | Location: "
                              + locationUpped
                              + " ");
                      plainOutputTxt.write(" | Date: "
                          + d.toString() + " ");
                      plainOutputTxt.write(" | Hash: "
                          + treeHash + " ");
                      plainOutputTxt
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputTxt.close();

                      plainOutputCsv.write(""
                          + thisResult + ",");
                      plainOutputCsv.write("" + thisFile
                          + ",");
                      plainOutputCsv.write(""
                          + fileLength + ",");
                      plainOutputCsv.write("" + vaultName
                          + ",");
                      plainOutputCsv.write(""
                          + locationUpped + ",");
                      plainOutputCsv.write(""
                          + d.toString() + ",");
                      plainOutputCsv.write("" + treeHash
                          + ",");
                      plainOutputCsv
                          .write(System
                              .getProperty("line.separator"));
                      plainOutputCsv.close();

                      uploadList
                          .add("Successfully uploaded "
                              + thisFile
                              + " to vault "
                              + vaultName
                              + " at "
                              + locationUpped
                              + ". Bytes: "
                              + fileLength
                              + ". ArchiveID Logged.\n");
                    }

                    // v0.4 logging code
                    // output.writeUTF("ArchiveID: " +
                    // thisResult + " ");
                    // output.writeUTF(" | File: " +
                    // thisFile + " ");
                    // output.writeUTF(" | Vault: "
                    // +vaultName + " ");
                    // output.writeUTF(" | Location: " +
                    // locationUpped + " ");
                    // output.writeUTF(" | Date: "+d.toString()+"\n\n");
                    catch (IOException c) {
                      JOptionPane.showMessageDialog(null,
                          LOG_WRITE_ERROR,
                          "IO Error",
                          JOptionPane.ERROR_MESSAGE);
                      uw.dispose();
                      System.exit(1);
                    }

                  } else {
                    JOptionPane
                        .showMessageDialog(
                            null,
                            "Upload Complete!\nArchive ID: "
                                + result.getArchiveId()
                                + "\nIt may take some time for Amazon to update the inventory.",
                            "Uploaded",
                            JOptionPane.INFORMATION_MESSAGE);
                    multiFiles = null;
                    uw.dispose();
View Full Code Here

TOP

Related Classes of com.amazonaws.services.glacier.transfer.UploadResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.