in uploader/src/main/scala/com/gu/media/upload/MultipartCopyChunkInS3.scala [30:59]
private def uploadPart(upload: Upload, progress: CopyProgress): CopyProgress = {
val part = progress.eTags.size
if(part >= upload.parts.size) {
log.error("Invoked CreateCompleteVideoInS3 handler even though all parts are uploaded")
progress.copy(fullyCopied = true)
} else {
val bucket = upload.metadata.bucket
val source = upload.parts(part).key
val destination = upload.metadata.pluto.s3Key
val request = new CopyPartRequest()
.withUploadId(progress.copyId)
.withSourceBucketName(bucket)
.withSourceKey(source)
.withDestinationBucketName(bucket)
.withDestinationKey(destination)
.withPartNumber(part + 1)
log.info(s"Copying $source to $destination [multipart=${progress.copyId} part=$part]")
val response = s3Client.copyPart(request)
val eTags = progress.eTags :+ CopyETag(response.getPartNumber, response.getETag)
progress.copy(
eTags = eTags,
fullyCopied = eTags.size == upload.parts.size
)
}
}