Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Upload to Amazon S3
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01530635
Message ID:
01530713
Vues:
64
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.

>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
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform