gradle 上传app至Amazon s3

import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.services.s3.transfer.TransferManager

def uploadApk(String bucketName, String keyPrefix, String uploadPath) {

    def credentials = new BasicAWSCredentials("${access_key}", "${secret_key}")
    def manager = new TransferManager(credentials)
    println "uploadpath:${uploadPath}"
    File file = file(uploadPath)

    def upload = manager.uploadDirectory(bucketName, keyPrefix, file, file.isDirectory())
    upload.waitForCompletion()
    println "Upload finished .."
    manager.shutdownNow()
}


   dependencies {
       
        classpath 'com.amazonaws:aws-java-sdk-s3:1.11.176'
    }

其中,access_key,secret_key ,是通过添加动态实时属性传入的。主要是调用亚马逊sdk中的相应方法

参考:https://github.com/rambabusaravanan

你可能感兴趣的:(gradle 上传app至Amazon s3)