Example #1
0
func (storer *DPNIngestStorer) copyToLongTermStorage(manifest *models.DPNIngestManifest) {
	manifest.StoreSummary.ClearErrors()
	upload := apt_network.NewS3Upload(
		constants.AWSVirginia,
		storer.Context.Config.DPN.DPNPreservationBucket,
		fmt.Sprintf("%s.tar", manifest.DPNBag.UUID),
		"application/x-tar")
	upload.AddMetadata("from_node", manifest.DPNBag.IngestNode)
	upload.AddMetadata("transfer_id", fmt.Sprintf("None - Ingested Directly at %s", manifest.DPNBag.IngestNode))
	upload.AddMetadata("member", manifest.DPNBag.Member)
	upload.AddMetadata("local_id", manifest.DPNBag.LocalId)
	upload.AddMetadata("version", fmt.Sprintf("%d", manifest.DPNBag.Version))
	reader, err := os.Open(manifest.LocalTarFile)
	if reader != nil {
		defer reader.Close()
	}
	if err != nil {
		manifest.StoreSummary.AddError("Error opening reader for tar file %s: %v",
			manifest.LocalTarFile, err)
		return
	}
	upload.Send(reader)
	if upload.ErrorMessage != "" {
		manifest.StoreSummary.AddError("Error uploading tar file %s: %s",
			manifest.LocalTarFile, upload.ErrorMessage)
		return
	}
	manifest.StorageURL = upload.Response.Location
}