Ralpharama Archive. The archive is almost 20 years old, this website is no longer maintained.

Home | New Writing | Old Writing | Cooking | Technical | Wine Making | Cocktails
   
 
Article

Use Chilkat S3_DownloadBytes and S3_UploadBytes to copy images

Hits 870 | Created 2016-10-04 | Modified 2016-10-04

Copy images between Amazon s3 buckets in memory only using Chilkat's S3_DownloadBytes and S3_UploadBytes. Example classic ASP code.

' Call the copy, the last param isn't used in the function
' Params: contentType, s3 bucketSourceName, s3bucketDestName, path-to-file, justFileName
Call http_copy_bytes("image/jpg",s3BucketName,s3DestBucketName,"webimages/image.jpg","image.jpg")

' Copy a file via memory
Function http_copy_bytes(contentType,bucketSourceName,bucketDestName,objectName,justFileName)
	Dim success, binaryImage

	' Set up chilkat http 
	Dim http : Set http = Server.CreateObject("Chilkat.Http")
	http_unlock(http)
	http.AwsAccessKey = AwsAccessKey	' your key
	http.AwsSecretKey = AwsSecretKey	' your key

	' Download image from source bucket
	binaryImage = http.S3_DownloadBytes(bucketSourceName,objectName)

	' Upload file to destination bucket
	success = http.S3_UploadBytes(binaryImage,contentType,bucketDestName,lcase(objectName))
	If (success < 1) Then
	    Response.Write Server.HTMLEncode( http.LastErrorText)
	Else
	    Response.Write Server.HTMLEncode( "File uploaded.")
	End If
	Set http = Nothing
End Function




Make a Comment

Name
Comment


Antispam Code (always a number)

Enter Code Above
Submit

Note: All HTML will be removed except for bold and italics. Links will not display. Line breaks are added automatically. Use <pre>...</pre> for code.

Tags

This item has the following tags:
amazon s3 tech buckets chilkat http

Useful? Donate for hosting costs

All content copyright (c) Ralpharama