in src/main/kotlin/com/jetbrains/notary/NotaryClientV2.kt [91:119]
fun uploadSoftware(
attributes: NewSubmissionResponse.Data.Attributes,
filepath: Path,
// The region is not given anywhere in the Apple documentation.
// Thanks to the folks that built https://github.com/indygreg/PyOxidizer, we got it's us-west-2...
s3Region: String = "us-west-2",
): PutObjectResult? {
val inputStream = filepath.inputStream().buffered()
val metadata = ObjectMetadata().also {
it.contentLength = filepath.fileSize()
}
val request = PutObjectRequest(
attributes.bucket,
attributes.`object`,
inputStream,
metadata,
)
val credentials = BasicSessionCredentials(
attributes.awsAccessKeyId,
attributes.awsSecretAccessKey,
attributes.awsSessionToken,
)
val s3Client = AmazonS3ClientBuilder
.standard()
.withCredentials(AWSStaticCredentialsProvider(credentials))
.withRegion(s3Region)
.build()
return s3Client.putObject(request)
}