write a function in kotlin to upload a local file to s3
- User
write a function in kotlin to upload a local file to s3
Assistant
Here's a simple function in Kotlin that uploads a local file to S3:
import com.amazonaws.services.s3.AmazonS3 import com.amazonaws.services.s3.AmazonS3ClientBuilder import java.io.File fun uploadToS3(localFilePath: String, bucket: String, key: String) { val s3client = AmazonS3ClientBuilder.standard().withRegion("us-west-2").build() val s3Object = s3client.getObject(bucket, key) val file = File.createTempFile("upload", ".txt") val outputStream = FileOutputStream(file) s3Object.writeTo(outputStream) outputStream.close() s3Object.delete() }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.