gradle-aws-plugin icon indicating copy to clipboard operation
gradle-aws-plugin copied to clipboard

AmazonS3FileUploadTask finishes but the file isn't uploaded

Open rok-tel opened this issue 9 years ago • 2 comments

hi, im developing a gradle process with AmazonS3FileUploadTask and trying to upload a file with it.

 task uploadContent(type: AmazonS3FileUploadTask) 
{
    println 'inside upload s3'
    file file("FILE_PATH")
    bucketName "plugin-layouts"
    key "KEY_NAME"
    /*def m = new ObjectMetadata()
    m.setCacheControl("no-cache, no-store")
    objectMetadata = m*/
    println 'end upload s3'
}

once i run "gradle war" i see the println rows, but the file aventually isn't uploaded the FILE_PATH im giving is relative to the project's build.gradle file the task is in.

any ideas why is it happening?

rok-tel avatar Oct 25 '15 15:10 rok-tel

Hi, I saw the same issue but I was able to fix it by add the file name to the key see my code below:

    file file("${props['s3.file.name']}") 
    bucketName "${props['s3.bucket.name']}"
    key "${props['s3.folder.name']}/${props['s3.file.name']}"

    ObjectMetadata m = new ObjectMetadata()
    m.setCacheControl("no-cache, no-store")

gwsu2008 avatar Nov 02 '15 18:11 gwsu2008

I faced the same issue. So I tried the command ./gradlew uloadContent --debug and found this line: 11:16:23.296 [INFO] [org.gradle.api.Task] s3://bucket-name/file-name already exists with matching md5 sum -- skipped The overwrite policy in default is false. Setting it false like overwrite = true should work. However, Putting it in a gradle task didn't work. I hope anyone shares how to do so.

task uploadContent(type: AmazonS3FileUploadTask) {

	file file('build/filepath.zip') // must be a file
	bucketName jobsBucketName
	key 'lambda-file-path'

	def m = new ObjectMetadata()
	m.setCacheControl("no-cache, no-store")
	objectMetadata = m
	overwrite = true

	println "overwrite: " + isOverwrite()
}

When debugging, overwrite prints out true, however it did not affect the overwrite policy of the gradle task.

pierceh89 avatar Jan 16 '17 02:01 pierceh89