Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Upload to Amazon S3
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01530635
Message ID:
01530722
Views:
66
>It looks like you missed one step
>
>Calculate a signature value (SHA-1 HMAC) from the encoded policy document using your AWS Secret Key credential as a password. Include this value in the form’s signature input field after Base64-encoding it.

Thanks Sergey. My code I posted was missing the conversion, but I have previously tried both

lcSignature=STRCONV(lcSignature,15)
and
lcSignature=STRCONV(lcSignature,13)

and still get 403 forbidden

I know that everything works on my S3 account because this works no problem:
http://www.example-code.com/foxpro/s3_uploadFile.asp

Any other ideas?



>
>>This article shows a simple POST Form web page for uploading a file to Amazon S3
>>http://aws.amazon.com/articles/1434
>>
>>How can I perform this upload with wwipstuff?
>>What I have so far yields result=403 Forbidden
>>
>>I'm guessing it has something to do with conversions (utf-8,base 64,etc.)???
>>
>>
>>LOCAL loIP as wwipstuff OF wwipstuff
>>loIP=NEWOBJECT('wwipstuff','wwipstuff')
>>loIP.nhttppostmode=2
>>
>>LOCAL lcPolicyDoc,lcPolicyDocEncoded,lcSignature
>>TEXT TO lcPolicyDoc NOSHOW PRETEXT 15
>>{"expiration": "2015-01-01T00:00:00Z",
>>  "conditions": [ 
>>    {"bucket": "mybucket"}, 
>>    ["starts-with", "$key", ""],
>>    {"acl": "public-read"},
>>    ["starts-with", "$Content-Type", ""],
>>    ["content-length-range", 0, 1048576]
>>  ]
>>}
>>ENDTEXT
>>lcPolicyDocEncoded=STRCONV(lcPolicyDoc,13)
>>lcSignature=hmac(lcPolicyDocEncoded,"SecretAccessKey",1)
>>
>>
>>loIP.cHTTPProxyName=""
>>IF loIP.HTTPConnect("mybucket.s3.amazonaws.com",'','',.T.)=0
>>	loIP.encodefile
>>	lcBuffer=loIP.encodefile("c:\images\myimage.jpg")
>>	
>>	loIP.AddPostKey('AWSAccessKeyId',"MyAccessKeyID")
>>	loIP.AddPostKey('bucket',"mybucket")
>>	loIP.AddPostKey('policy',lcPolicyDocEncoded)
>>	loIP.AddPostKey('signature',lcSignature)
>>	
>>	** image specific 
>>	loIP.AddPostKey('acl',"public-read")
>>	loIP.AddPostKey('Content-Type',"image/jpeg")
>>	
>>	loIP.AddPostKey('key',"myimage.jpg")
>>	loIP.AddPostKey('file',lcBuffer)
>>	
>>	lcOutput=""
>>	lnSize=0
>>	
>>	lnResult=loIP.HTTPGetEx([],@lcOutput,@lnSize)
>>	loIP.HTTPClose
>>	IF lnResult=0
>>		** good
>>		? 'success'
>>	ELSE
>>		? 'error '+loIP.cerrormsg+' '+lcOutput
>>	ENDIF
>>ELSE
>>	? 'error '+loIP.cerrormsg
>>ENDIF
>>
Brandon Harker
Sebae Data Solutions
Previous
Reply
Map
View

Click here to load this message in the networking platform