Copy Pictures to S3

Edit this page ...


	(PRScheduledTaskExamples newForKernelNamed: 'pier')
		copyImageFilesFrom: '/'
		usingNaming: [ :file |
			'https://' , (PRScheduledTaskExamples
				 stringProperty: 'AwsPictureBucket'
				 ifAbsent: [ 'test-serve-pictures001' ]) , '.s3.'
			, (PRScheduledTaskExamples
					 stringProperty: 'AwsRegion'
					 ifAbsent: [ 'us-east-2' ]) , '.amazonaws.com/' , file title ]
		toExternalUsing: [ :files |
			files do: [ :prf |
				| bucketName |
				bucketName := PRScheduledTaskExamples
					              stringProperty: 'AwsPictureBucket'
					              ifAbsent: [ 'test-serve-pictures001' ].
				((AWSS3Bucket newWithBucket: bucketName) listObjects objects
					 contains: [ :item | item key = prf title ])
					ifTrue: [
						Transcript
							show: 'The file exists!';
							cr ]
					ifFalse: [
						(AWSS3Bucket newWithBucket: bucketName)
							put: (ZnByteArrayEntity bytes: prf contents asByteArray)
							key: prf title ] ] ]
		reportOn:
		'/Blog/Social Tasks/Democracy Action/Copy Pictures to S3/Report'.