public DeleteArchive ( string vaultName, string archiveId ) : void | ||
vaultName | string | The name of the vault containing the archive. |
archiveId | string | The archive ID of the archive to delete. |
return | void |
static void Main(string[] args) { if (CheckRequiredFields()) { using (manager = new ArchiveTransferManager(RegionEndpoint.USWest2)) { try { // Creates a new Vault Console.WriteLine("Create Vault"); manager.CreateVault(vaultName); // Uploads the specified file to Glacier. Console.WriteLine("Upload a Archive"); var uploadResult = manager.Upload(vaultName, "Archive Description", filePath); archiveId = uploadResult.ArchiveId; Console.WriteLine("Upload successful. Archive Id : {0} Checksum : {1}", uploadResult.ArchiveId, uploadResult.Checksum); // Downloads the file from Glacier // This operation can take a long time to complete. // The ArchiveTransferManager.Download() method creates an Amazon SNS topic, // and an Amazon SQS queue that is subscribed to that topic. // It then initiates the archive retrieval job and polls the queue for the // archive to be available. This polling takes about 4 hours. // Once the archive is available, download will begin. Console.WriteLine("Download the Archive"); var options = new DownloadOptions(); options.StreamTransferProgress += OnProgress; manager.Download(vaultName, archiveId, downloadFilePath, options); Console.WriteLine("Delete the Archive"); manager.DeleteArchive(vaultName, archiveId); } catch (AmazonGlacierException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } } } }
private Exception deleteArchive(ArchiveTransferManager manager, KeyValuePair<string, List<Archive>> entryInThis, Archive archive) { int rep = 0; Exception error = null; isDirty = true; do { if (rep > 0) { Thread.Sleep(2000); } try { DateTime start = DateTime.Now; manager.DeleteArchive(VaultName, archive.ArchiveId); DeleteTime += DateTime.Now.Subtract(start); entryInThis.Value.Remove(archive); inventoryById.Remove(archive.ArchiveId); if (entryInThis.Value.Count == 0) { inventoryByPath.Remove(entryInThis.Key); } toDelete.Remove(archive); } catch(Exception ex) { error = ex; } } while (++rep < 4 && error != null); return error; }