ImportManifestRoot CreateImportManifest(string fileFormat,
long? volumeSize)
{
try
{
var urlExpiration = AWSSDKUtils.CorrectedUtcNow.AddDays(UrlExpiryPeriod);
ConstructManifestArtifactKey(ImageFilePath);
var format = fileFormat;
if (string.IsNullOrEmpty(format))
{
var ext = AWSSDKUtils.GetExtension(ImageFilePath);
if (string.IsNullOrEmpty(ext))
throw new ArgumentException("The image filename does not have an exception, so file format cannot be inferred.");
format = ext.TrimStart('.');
}
var manifest = new ImportManifestRoot
{
Version = ManifestFileVersion,
FileFormat = format.ToUpper(CultureInfo.InvariantCulture),
ImporterField = new ImporterInfo
{
Name = ManifestFileImporterName,
Version = ManifestFileImporterVersion,
Release = ManifestFileImporterRelease
},
SelfDestructUrl = S3Client.GeneratePreSignedURL(
BucketName,
ManifestFileKey,
urlExpiration,
new Dictionary<string, object>{{"Verb", "DELETE"}}),
ImportData = ConstructImportPartsList(volumeSize, urlExpiration)
};
return manifest;
}
catch (Exception e)
{
throw new DiskImageImporterException(DiskImportErrorStage.GeneratingManifest, e);
}
}