/// <summary> /// Constructs an importer instance for a previously uploaded manifest. The manifest is downloaded using /// a new Amazon S3 client constructed for the specified region and deserialized, ready for use in /// constructing the appropriate ImportInstance or ImportVolume request to Amazon EC2. /// </summary> /// <param name="credentials"> /// The AWS credentials for the account that owns or has access to the bucket containing the manifest file. /// </param> /// <param name="region">The region in which the Amazon S3 client used for download will be constructed.</param> /// <param name="bucketName">The name of the bucket containing the manifest file.</param> /// <param name="manifestFileKey">The S3 object key of the manifest file.</param> /// <param name="resumingUpload"> /// Set this to true if a previous upload failed part-way through processing and RetainArtifactsOnUploadError /// was set to true so the partially uploaded content was retained. The existing manifest will /// be inspected and uploads can then resume to process the retaining content. /// </param> /// <returns>Initialized importer instance containing a deserialized manifest</returns> public static DiskImageImporter FromManifest(AWSCredentials credentials, RegionEndpoint region, string bucketName, string manifestFileKey, bool resumingUpload) { try { var importer = new DiskImageImporter(credentials, region, bucketName) { ManifestFileKey = manifestFileKey }; importer.DeserializeManifestFromS3(); if (resumingUpload) importer.DetermineRemainingUploads(); return importer; } catch (AmazonS3Exception e) { var msg = string.Format(CultureInfo.InvariantCulture, "Failed to download the specified manifest from bucket {0} with key {1}", bucketName, manifestFileKey); throw new DiskImageImporterException(DiskImportErrorStage.ManifestInspection, msg, e); } catch (XmlException e) { throw new DiskImageImporterException(DiskImportErrorStage.ManifestInspection, "Failed to deserialize the downloaded manifest", e); } }