Tag: 上传

并行S3文件通过Kotlin协程上传

我需要上传许多文件到S3,这将需要数小时才能顺利完成这项工作。 这正是Kotlin的新协程所擅长的,所以我想给他们一个尝试,而不是再次用一些基于线程的执行服务来摆弄。 这是我的(简体)代码: fun upload(superTiles: Map<Int, Map<Int, SuperTile>>) = runBlocking { val s3 = AmazonS3ClientBuilder.standard().withRegion("eu-west-1").build() for ((x, ys) in superTiles) { val jobs = mutableListOf<Deferred<Any>>() for ((y, superTile) in ys) { val job = async(CommonPool) { uploadTile(s3, x, y, superTile) } jobs.add(job) } jobs.map { it.await() } } } suspend fun uploadTile(s3: AmazonS3, x: Int, […]