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();