/// <summary> /// <para> /// Uploads the specified file to Amazon Glacier for archival storage in the /// specified vault in the specified user's account. For small archives, this /// method uploads the archive directly to Glacier. For larger archives, /// this method uses Glacier's multipart upload API to split the upload /// into multiple parts for better error recovery if any errors are /// encountered while streaming the data to Amazon Glacier. /// </para> /// </summary> /// <param name="vaultName">The name of the vault to download the archive from.</param> /// <param name="archiveDescription">A description for the archive.</param> /// <param name="filepath">The file path to the file to upload.</param> /// <param name="options">Additional options that can be used for the upload.</param> /// <returns>The results of the upload including the archive ID.</returns> public UploadResult Upload(string vaultName, string archiveDescription, string filepath, UploadOptions options) { FileInfo fi = new FileInfo(filepath); BaseUploadCommand command; if (fi.Length > MULTIPART_UPLOAD_SIZE_THRESHOLD) command = new MultipartUploadCommand(this, vaultName, archiveDescription, filepath, options); else command = new SinglepartUploadCommand(this, vaultName, archiveDescription, filepath, options); command.Execute(); return command.UploadResult; }
/// <summary> /// <para> /// Uploads the specified file to Amazon Glacier for archival storage in the /// specified vault in the specified user's account. For small archives, this /// method uploads the archive directly to Glacier. For larger archives, /// this method uses Glacier's multipart upload API to split the upload /// into multiple parts for better error recovery if any errors are /// encountered while streaming the data to Amazon Glacier. /// </para> /// </summary> /// <param name="vaultName">The name of the vault to download the archive from.</param> /// <param name="archiveDescription">A description for the archive.</param> /// <param name="filepath">The file path to the file to upload.</param> /// <param name="options">Additional options that can be used for the upload.</param> /// <returns>The results of the upload including the archive ID.</returns> public async Task <UploadResult> UploadAsync(string vaultName, string archiveDescription, string filepath, UploadOptions options) { FileInfo fi = new FileInfo(filepath); BaseUploadCommand command; if (fi.Length > MULTIPART_UPLOAD_SIZE_THRESHOLD) { command = new MultipartUploadCommand(this, vaultName, archiveDescription, filepath, options); } else { command = new SinglepartUploadCommand(this, vaultName, archiveDescription, filepath, options); } await command.ExecuteAsync().ConfigureAwait(false); return(command.UploadResult); }
/// <summary> /// <para> /// Uploads the specified file to Amazon Glacier for archival storage in the /// specified vault in the specified user's account. For small archives, this /// method uploads the archive directly to Glacier. For larger archives, /// this method uses Glacier's multipart upload API to split the upload /// into multiple parts for better error recovery if any errors are /// encountered while streaming the data to Amazon Glacier. /// </para> /// </summary> /// <param name="vaultName">The name of the vault to download the archive from.</param> /// <param name="archiveDescription">A description for the archive.</param> /// <param name="filepath">The file path to the file to upload.</param> /// <param name="options">Additional options that can be used for the upload.</param> /// <returns>The results of the upload including the archive ID.</returns> public UploadResult Upload(string vaultName, string archiveDescription, string filepath, UploadOptions options) { FileInfo fi = new FileInfo(filepath); BaseUploadCommand command; if (fi.Length > MULTIPART_UPLOAD_SIZE_THRESHOLD) { command = new MultipartUploadCommand(this, vaultName, archiveDescription, filepath, options); } else { command = new SinglepartUploadCommand(this, vaultName, archiveDescription, filepath, options); } command.Execute(); return(command.UploadResult); }
public static void Upload(string[] args) { string id = args[0]; string access = args[1]; string secret = args[2]; RegionEndpoint region = ParseRegion(args[3]); string vault = args[4]; string path = args[5]; string desc = args[6]; var info = new FileInfo(path); long size = 0; if (info.Exists) size = info.Length; else { Console.Error.Write("The given path does not exist.\n"); Usage(); } Console.Write("About to perform the following upload:\n\n" + String.Format("{0,-16}{1}\n", "Path:", path) + String.Format("{0,-16}{1:f6} GiB\n", "Size:", (decimal)size / (1024m * 1024m * 1024m)) + String.Format("{0,-16}\"{1}\"\n", "Description:", desc) + String.Format("\n{0,-16}{1}\n", "Region:", region.DisplayName) + String.Format("{0,-16}{1}\n", "Vault:", vault) + String.Format("\n{0,-16}${1:f2}/month\n", "Storage cost:", ((decimal)size / (1024m * 1024m * 1024m) * 0.01m)) + String.Format("{0,-16}${1:f2} (< 90 days)\n", "Deletion fee:", ((decimal)size / (1024m * 1024m * 1024m) * 0.03m)) + String.Format("{0,-16}${1:f2}\n", "Retrieval cost:", ((decimal)size / (1024m * 1024m * 1024m) * 0.12m)) + String.Format("\n{0,-16}{1}\n", "Account ID:", id) + String.Format("{0,-16}{1}\n", "Access key:", access) + String.Format("{0,-16}{1}\n", "Secret key:", secret) + "\nARE YOU SURE YOU WANT TO PROCEED? [y/N] "); bool proceed = false; do { ConsoleKeyInfo key = Console.ReadKey(true); switch (Char.ToLower(key.KeyChar)) { case 'y': Console.WriteLine(key.KeyChar); proceed = true; break; case 'n': Console.Write(key.KeyChar); goto case '\n'; case '\n': Console.WriteLine(); Console.Write("Upload aborted.\n"); Environment.Exit(0); break; } } while (!proceed); Console.Write("\nUpload started at {0:G}.\n", DateTime.Now); Console.CancelKeyPress += CtrlC; var progress = new Progress(); var options = new UploadOptions(); options.AccountId = id; options.StreamTransferProgress += progress.Update; var creds = new BasicAWSCredentials(access, secret); var manager = new ArchiveTransferManager(creds, region); progress.Start(); /* not asynchronous */ UploadResult result = manager.Upload(vault, desc, path, options); Console.Write("\n\nUpload complete.\n" + String.Format("Archive ID: {0}\n", result.ArchiveId)); }
private void uploadArchive_Click(object sender, EventArgs e) { OpenFileDialog openfile = new OpenFileDialog(); if (openfile.ShowDialog() != DialogResult.OK) { return; } try { ArchiveTransferManager manager = this.getManager(); UploadOptions options = new UploadOptions(); options.StreamTransferProgress += this.progress; progressBar1.Value = 0; UploadResult upload = manager.Upload(vaultName.Text, "description", openfile.FileName, options); archiveId.Text = upload.ArchiveId; MessageBox.Show("upload complete" + openfile.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// <para> /// Uploads the specified file to Amazon Glacier for archival storage in the /// specified vault in the specified user's account. For small archives, this /// method uploads the archive directly to Glacier. For larger archives, /// this method uses Glacier's multipart upload API to split the upload /// into multiple parts for better error recovery if any errors are /// encountered while streaming the data to Amazon Glacier. /// </para> /// </summary> /// <param name="vaultName">The name of the vault to download the archive from.</param> /// <param name="archiveDescription">A description for the archive.</param> /// <param name="filepath">The file path to the file to upload.</param> /// <param name="options">Additional options that can be used for the upload.</param> /// <returns>The results of the upload including the archive ID.</returns> public async Task<UploadResult> UploadAsync(string vaultName, string archiveDescription, string filepath, UploadOptions options) { FileInfo fi = new FileInfo(filepath); BaseUploadCommand command; if (fi.Length > MULTIPART_UPLOAD_SIZE_THRESHOLD) command = new MultipartUploadCommand(this, vaultName, archiveDescription, filepath, options); else command = new SinglepartUploadCommand(this, vaultName, archiveDescription, filepath, options); await command.ExecuteAsync().ConfigureAwait(false); return command.UploadResult; }
public FDGlacier(FDUserSettings settings, FDOperationLog oplog, string optype) { this.vaultName = settings.AWSGlacierVaultName; log = oplog; switch (settings.AWSRegion) { case FDUserSettings.AWSRegionIndex.USWest1: region = RegionEndpoint.USWest1; break; case FDUserSettings.AWSRegionIndex.USWest2: region = RegionEndpoint.USWest2; break; case FDUserSettings.AWSRegionIndex.USEast1: region = RegionEndpoint.USEast1; break; case FDUserSettings.AWSRegionIndex.EUWest1: region = RegionEndpoint.EUWest1; break; case FDUserSettings.AWSRegionIndex.APNortheast1: region = RegionEndpoint.APNortheast1; break; default: region = RegionEndpoint.USEast1; break; } //Instantiate the glacier config with our settins (for future move to AmazonGlacierClient) glacierConfig = new AmazonGlacierConfig(); glacierConfig.RegionEndpoint = region; //Instantiate AWS Credentials awsCredentials = new BasicAWSCredentials(settings.AWSAccessKey, settings.AWSSecretKey); //Instantiate the transfer manager with our settings //TODO: Switch to glacier client so we can abort this damn thing //glacierClient = new AmazonGlacierClient(appConfig["AWSAccessKey"], appConfig["AWSSecretKey"], region); transferManager = new ArchiveTransferManager(awsCredentials, region); upOptions = new UploadOptions(); downOptions = new DownloadOptions(); progress = 0; upOptions.StreamTransferProgress = downOptions.StreamTransferProgress = this.onProgress; OperationType = optype; }