Classic ASP
Classic ASP
Demonstrate S3_UploadBytes
Demonstrates how to upload a file to the Amazon S3 service.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example assumes the Chilkat HTTP API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set http = Server.CreateObject("Chilkat.Http")
http.AwsAccessKey = "AWS_ACCESS_KEY"
http.AwsSecretKey = "AWS_SECRET_KEY"
bucketName = "chilkat.qa"
objectName = "images/sea_creatures/starfish.jpg"
localFilePath = "qa_data/jpg/starfish.jpg"
contentType = "image/jpg"
set jpgData = Server.CreateObject("Chilkat.BinData")
success = jpgData.LoadFile(localFilePath)
If (Not success) Then
Response.Write "<pre>" & Server.HTMLEncode( "Failed to load " & localFilePath) & "</pre>"
Response.End
End If
jpgBytes = jpgData.GetBinary()
success = http.S3_UploadBytes(jpgBytes,contentType,bucketName,objectName)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Success. File uploaded.") & "</pre>"
%>
</body>
</html>