Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload to s3 directly from Flash 403 issue
    primarykey
    data
    text
    <p>there are quite a few ways to upload to S3 from flash. I am trying to implement code from the following example on Amazon's site <a href="http://aws.amazon.com/code/1092?_encoding=UTF8&amp;jiveRedirect=1" rel="nofollow">http://aws.amazon.com/code/1092?_encoding=UTF8&amp;jiveRedirect=1</a></p> <p>Some posts that I ran across indicated that a lot of the fields from Amazon are now Requiered and unless you fill them in you will get this dreaded 403 error. </p> <p>I have tried several things and I am hoping there will be a solution soon. I used the following libs from here <a href="http://code.google.com/p/as3awss3lib/" rel="nofollow">http://code.google.com/p/as3awss3lib/</a>.</p> <p>Here is my class that handles all the uploading</p> <pre><code>package com.myemma.s3uploader.main.controllers { import jp.classmethod.aws.core.AWSEvent; import s3.flash.S3PostOptions; import s3.flash.S3PostRequest; import utils.PolicyGenerator; import com.myemma.s3uploader.main.model.MainDM; import com.myemma.s3uploader.settings.Settings; import flash.events.DataEvent; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; import flash.events.SecurityErrorEvent; import flash.external.ExternalInterface; import flash.net.FileReference; /** * @author Matthew Sloan Wallace - http://mattwallace.me */ public class UploadFilesAction extends EventDispatcher { [Inject] public var dm : MainDM; private var service : S3PostRequest; [Init] public function onInit() : void { if (ExternalInterface.available) ExternalInterface.addCallback( "uploadFiles", uploadFiles ); } private function uploadFiles() : void { if (dm.selectedFiles) upload(); } private function upload() : void { if (dm.selectedFiles.length &gt; 0) { var fileReference : FileReference = dm.selectedFiles[0]; // var s3:AWSS3 = new AWSS3(Settings.accessKey, Settings.secret_key); // s3.saveObject("mattwallace", fileReference.name, "image/png", fileReference); // s3.addEventListener("objectSaved", onObjectSaved); var policy : PolicyGenerator = PolicyGenerator.getInstance( Settings.accessKey, Settings.secret_key ); var s3Options : S3PostOptions = new S3PostOptions(); s3Options.secure = false; s3Options.acl = "private"; s3Options.contentType = "image/png"; s3Options.filename = fileReference.name; s3Options.success_action_status = "201"; s3Options.policy = policy.policy; s3Options.signature = policy.signature; service = new S3PostRequest( Settings.accessKey, Settings.bucket, Settings.secret_key, s3Options ); service.addEventListener( Event.OPEN, function( event : Event ) : void { trace( "Uploading..." ); trace( "Upload started: " + fileReference.name ); } ); service.addEventListener( ProgressEvent.PROGRESS, function( event : ProgressEvent ) : void { trace( Math.floor( event.bytesLoaded / event.bytesTotal * 100 ) ); } ); service.addEventListener( IOErrorEvent.IO_ERROR, function( event : IOErrorEvent ) : void { trace( "Upload error!" ); trace( "An IO error occurred: " + event ); } ); service.addEventListener( SecurityErrorEvent.SECURITY_ERROR, function( event : SecurityErrorEvent ) : void { trace( "Upload error!" ); trace( "A security error occurred: " + event ); } ); service.addEventListener( DataEvent.UPLOAD_COMPLETE_DATA, function( event : Event ) : void { trace( "Upload complete!" ); trace( "Upload completed: " + event ); dm.selectedFiles.splice( 0, 1 ); } ); try { service.upload( fileReference ); } catch(e : Error) { trace( "Upload error!" ); trace( "An error occurred: " + e ); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload