Git Product home page Git Product logo

nathancolgate / s3-swf-upload-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prx/s3-swf-upload-plugin

318.0 4.0 74.0 5.69 MB

A rails 3 gem which allow user upload files to S3 through an embedded flash directly. All UI has been moved out of flex and can be controlled by CSS and JavaScript callbacks.

Home Page: http://www.nathancolgate.com

License: MIT License

Ruby 34.28% Shell 0.25% ActionScript 65.47%

s3-swf-upload-plugin's Introduction

S3SwfUpload Gem For Rails 3

S3SwfUpload allows user to upload a file to S3 directly, so you can save the cost of uploading process in your app server.

The flex application in this fork was completely re-written so that there are no flash or flex UI components. The one exception to that is the browse button, which, for security purposes MUST be flash. But even then, you get to pass the URLs for images to use for that button!

The goal of this re-write is to put the power to customize this powerful took back in the hands of non-flex-savvy developers. The look and feel is controlled by CSS, and any behavior is controlled by JavaScript. Flex only handles the file management portion. A nice result of this is that the flash file is only 46 kb, down from 288 kb. If you see any way that this can be done better, please don’t hesitate to let me know!

Example

Watch a video of an example app being built using the gem on Vimeo

There is also a demo app running on heroku at http://s3swfuploader.heroku.com/

Usage

1. Edit Gemfile and add this as a gem

gem 's3_swf_upload'

Or:

gem 's3_swf_upload', :git => 'git://github.com/nathancolgate/s3-swf-upload-plugin'

2. Bundle it!

$ bundle install

3. Run the generator

$ rails generate s3_swf_upload:uploader

If you are using Rails 3.1, you will need to move the generated s3_upload.js from the public/javascripts directory to the app/assets/javascripts directory.

4. Configure your amazon parameters via the generated config/amazon_s3.yml file.
(key and secret can optionally be removed from that file and configured via ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY'])

5. Make the bucket

There used to be a rake task for this, but it was removed so that there would be no dependency of aws/s3.

6. Upload the crossdomain.xml file to the root of your S3 Bucket.

There used to be a rake task for this, but it was removed so that there would be no dependency of aws/s3.

Make sure the file is in the root of your bucket and is publicly readable.

7. Note: you no longer need to edit app/controller/s3_uploads_controller.rb

In my tests in Rails 3, the application was able to correctly handle the requests from the flash object.

This means that your authentication systems can still be used to protect the signature generation.

8. Initialize the SWF object in your view using this handy helper:

<%=raw s3_swf_upload_tag %>

9. To achieve basic functionality, the only other thing you need is something to call the startUploading function. For example:

<input type="submit" value="Start Uploading" onclick="s3_swf_1_object.startUploading();" />

However, you will have no feedback or interface to let you know that anything is actually happening.

10. If you want to customise its behavior, here’s a more complex example

And the CSS to go along.

File Renaming

In my applications I upload all files to tmp folder and then have rails manipulate the file (renaming, resizing, etc). Here’s a starting point to give you an idea of what that looks like using Paperclip:

How to integrate with Paperclip

I prefer this solution because it allows the application to keep tabs on the files. However, if you are looking for a pure javascript solution, check out some of the forks of this project.

General Parameters

:buttonWidth (integer = 100)

:buttonHeight (integer = 30)

:flashVersion (string = ‘9.0.0’)

:queueSizeLimit (integer = 100)

Maximum number of files that can be added to the queue.

:fileSizeLimit (integer = 524288000)

Individual file size limit in bytes (default is 512 MB)

:fileTypes (string = ‘.’)

Something like this also works: '*.jpg;*.gif;*.png;'

:fileTypeDescs (string = ‘All Files’)

Something like this also works: 'Image files.'

:selectMultipleFiles (boolean = true)

Set this to false if you only want to allow users to pick one file at a time.

:keyPrefix (string = ’’)

String to be prepended to the uploaded file name to make the Amazon S3 key (location in bucket).

:signaturePath (string = ‘/s3_uploads.xml’)

Fully qualified path to the controller and action that will serve up the Amazon S3 signature

:swfFilePath (string = ‘/flash/s3_upload.swf’)

Fully qualified path to the SWF file (this is the one that does all the work).

:buttonUpPath (string = ‘/flash/s3_up_button.gif’)

Fully qualified path to an image to be used as the Browse Button (in the up state). Image should have same dimensions as the buttonWidth and buttonHeight parameters.

:buttonOverPath (string = ‘/flash/s3_over_button.gif’)

Fully qualified path to an image to be used as the Browse Button (in the over state). Image should have same dimensions as the buttonWidth and buttonHeight parameters.

:buttonDownPath (string = ‘/flash/s3_down_button.gif’)

Fully qualified path to an image to be used as the Browse Button (in the down state). Image should have same dimensions as the buttonWidth and buttonHeight parameters.

Callback Parameters

The real power of this refactoring is that the flex application makes all of the following calls to JavaScript. What you do with the calls is totally up to you:

  • :onFileAdd (file)
  • :onFileRemove (file)
  • :onFileSizeLimitReached (file)
  • :onFileNotInQueue (file)
  • :onQueueChange (queue)
  • :onQueueSizeLimitReached (queue)
  • :onQueueEmpty (queue)
  • :onQueueClear (queue)
  • :onUploadingStart ()
  • :onUploadingStop ()
  • :onUploadingFinish ()
  • :onSignatureOpen (file,event)
  • :onSignatureProgress (file,progress_event)
  • :onSignatureSecurityError (file,security_error_event)
  • :onSignatureComplete (file,event)
  • :onSignatureIOError (file,io_error_event)
  • :onSignatureHttpStatus (file,http_status_event)
  • :onSignatureXMLError (file,error_message)
  • :onUploadError (upload_options,error)
  • :onUploadOpen (upload_options,event)
  • :onUploadProgress (upload_options,progress_event)
  • :onUploadIOError (upload_options,io_error_event)
  • :onUploadHttpStatus (upload_options,http_status_event)
  • :onUploadSecurityError (upload_options,security_error_event)
  • :onUploadComplete (upload_options,event)

JavaScript Functions

The following functions can be called on the generated object. Normally the call looks something like this:

s3_swf_1_object.startUploading();

startUploading

Starts the uploading process

stopUploading

Stops the uploading process. Note: Stopping and restarting the uploading process is buggy. I’d avoid it.

clearQueue

Clears all files out of the queue.

removeFileFromQueue(integer)

Removes a specific file from the queue.

Will it work with < Rails 3?

You bet. The Rails 3 specific gem only makes installation and setup easier. Here are some tips for getting this to work with < Rails 3:

  • install it as a plugin script/plugin install git://github.com/nathancolgate/s3-swf-upload-plugin.git
  • copy the template files into your application (use the generator as a road map)
  • copy the view helpers into your applications /lib directory.
  • add the view helper and integer monkey patch to an initialization file:
    require 'view_helpers' require 'patch/integer'
  • load the config file by adding this to the bottom of your environment.rb file: S3SwfUpload::S3Config.load_config
  • replace references to Rails.root or Rails.env in the /vendor/plugins/s3-swf-upload-plugin/lib/s3_swf_upload/s3_config.rb file.
  • comment out the require railties inside /vendor/plugins/s3-swf-upload-plugin/lib/s3_swf_upload.rb
  • you may need to require ‘s3_swf_upload’ and ‘aws/s3’ in your environment.rb file
  • your route will be map.resources instead of resources.

Known Issues

1. As much as I would like the interface to be 100% HTML, a (legitimate) security feature in Flash does not allow it:

“With Adobe Flash Player 10, the FileReference.browse and FileReference.download operations may be initiated only through ActionScript that originates from user interaction.” – Adobe TechNote

The next best thing I could come up with was to pass images in as buttons.

If the startUploading call is made after calling stopUploading, only the first file in the queue is successfully uploaded.

Kudos

Original plugin is Copyright © 2008 elctech, released under the MIT license

Updates to plugin for multiple file uploader are Copyright © 2010 PRX, released under the MIT license

Conversion of plugin to gem for rails 3 is Copyright © 2010 Nathan Colgate Clark, released under the MIT license

Stripping the flex application of UI and adding callbacks Copyright © 2010 Nathan Colgate Clark, released under the MIT license

Thanks to yickster (Nick Merwin) for fixing the stopUploading issue

s3-swf-upload-plugin's People

Contributors

ahoward avatar alex-kononovich avatar andrewculver avatar darcy avatar hampei avatar jacobevans avatar jasondew avatar jkillian avatar kookster avatar lgn21st avatar mveytsman avatar natebeck avatar nathancolgate avatar nickmerwin avatar taybenlor avatar yuki24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

s3-swf-upload-plugin's Issues

Heroku ActionView::Template::Error (s3_upload.js isn't precompiled)

I am currently trying to use this plugin on a Heroku Rails 3.1.3 application.

I have this in my gemfile.

gem 's3_swf_upload', :git => 'git://github.com/nathancolgate/s3-swf-upload-plugin'
gem 'aws-s3', :require => 'aws/s3'

I bundled the gem into my application, generated the rails code, created a new controller and view, and added the following to the view.

<%=raw s3_swf_upload_tag %>
<input type="submit" value="Start Uploading" onclick="s3_swf_1_object.startUploading();" />

I have added, committed and pushed all files to the heroku master. I am getting the following error.

2011-12-27T17:53:14+00:00 app[web.1]: Completed 500 Internal Server Error in 129ms
2011-12-27T17:53:14+00:00 app[web.1]:
2011-12-27T17:53:14+00:00 app[web.1]: ActionView::Template::Error (s3_upload.js isn't precompiled):
2011-12-27T17:53:14+00:00 app[web.1]: 1: <div id="wrapper">
2011-12-27T17:53:14+00:00 app[web.1]: 2: <h1>Uploader</h1>
2011-12-27T17:53:14+00:00 app[web.1]: 4: <input type="submit" value="Start Uploading" onclick="s3_swf_1_object.startUploading();" />
2011-12-27T17:53:14+00:00 app[web.1]: 3: <%=raw s3_swf_upload_tag %>
2011-12-27T17:53:14+00:00 app[web.1]: 5: </div>
2011-12-27T17:53:14+00:00 app[web.1]: app/views/pages/home.html.erb : 3 : in `_app_views_pages_home_html_erb___2628368205308588842_20282460'

I have also tried running the following.

bundle exec rake assets:precompile

'File not found in the queue'

Configured app as per instructions, including;

:onFileNotInQueue => "alert('File not found in the queue');",

  1. Click browse
  2. Add files
  3. Click 'delete' on one of the files in the list.
  4. See popup alert 'File not found in the queue' (but file is removed from the list OK).

Problem also exists on demo app: http://s3swfuploader.heroku.com/

Unidentifiable Upload Error

I followed the installation directions, but I get an error in my browser saying "There was an error" and the following stuff in my server console: (Rails 3.0.3, Ruby 1.9.2.)

Started GET "/s3_uploads.xml?key=apAsm%2Epng&content%5Ftype=image%2Fpng" for 127.0.0.1 at 2011-01-06 21:41:32 -0800
Processing by S3UploadsController#index as XML
Parameters: {"key"=>"apAsm.png", "content_type"=>"image/png"}
Completed 200 OK in 5ms (Views: 3.3ms | ActiveRecord: 0.0ms)

Thanks!

Question marks "?" and forward slashes "/" completely change file names

Hi Nathan,

First, allow me to say how much I love this uploader!

Second, I've noticed that files with question marks in their titles "image?.jpg" strip everything after the question mark, including the mark itself. In addition, anything with with a forward slash "image/.jpg" in the title strips everything before the forward slash, including the forward slash itself.

The issue is that the name is also changed in the javascript array of files so I can't access the original name for some post processing after the upload occurs.

Is there some way via Javascript to relax the way this is being interpreted?
If not, would you mind pointing out in the code where you're stripping this out and how I can recompile the swf?

Thanks,
-a

Question: Possible to change destination name entirely?

Currently when the S3 upload finished, regardless of the keyPrefix you give it, it will tack the original file name on to the end of this keyPrefix. Is it at all possible to write an entirely new name for the s3 destination?

this.obj().startUploading is not a function http://localhost:3000/javascripts/s3_upload.js?1329378949 Line 80

Hello,

This is a weird one. The upload doesn't start but firebug doesn't show any JS errors.

However, when I try to execute "s3_swf_1_object.startUploading();" in the firebug console, I get the below error -
this.obj().startUploading is not a function http://localhost:3000/javascripts/s3_upload.js?1329378949 Line 80

This seemed to be working fine in a previous commit but is now broken.
I have not made any significant changes to this part of the code.

Been trying to figure which change broke this for the past 2 days, but I don't seem to be getting anywhere!

Any help would be highly appreciated..

Generator tells me to run the generator

% rails generate s3_swf_uploader:uploader
% WARNING: You are using the S3 SWF Uploader gem, which wants a config file at /../config/amazon_s3.yml, but none could be found. You should try running 'rails generate s3_swf_upload:uploader'

Infinite loop of WARNINGS!

Uploads bigger than 2GB

Does it support uploads bigger than 2GB? From my tests, it just hangs. I've read something related to flash limits on upload sizes.

clearQueue() method does not work.

I looked at the actionscript code, and I believe it's because clearQueue calls this.removeAll() - and I can't find a definition for removeAll anywhere in the source.

Does this work with self-signed certificates?

I've really been pulling my hair out over this one. I have a fork of this project that I've been using successfully for a while. Now I'm trying to integrate it into a project that is secure over HTTPS, but I'm getting errors which lead me to believe it's a problem with Flash trying to fetch the signature XML over HTTPS. The onSignatureIOError function is getting called with an io_error_event.text of Error #2032. Is it a known issue that the SWF has problems with self-signed certificates? Or could it be something I'm not even thinking of?

Feature request: Change filename & keyPrefix through JavaScript after init

Hi Nathan

Love this plugin btw, you have really saved the day for me today...

One thing that would be really nice however would be to allow a filename & keyPrefix to be explicitly set for the SwfUpload object after it's been initialized. The reason I need this is as follows:

  • Form is shown to user, but user model is not yet created for that user as we don't have their details.
  • They fill in all their details in the form and select an avatar at the same time
  • User submits the form, however we catch this and use some AJAX to send the form data to the controller which in turn creates a model. We now have a user ID which is returned back to the browser via AJAX.
  • At this point I want to tell SwfUpload to use a path for this user such as /user/50/avatar/ and name the file original.jpg. This will ensure that users can never upload over other user's images and also negates the need for me to move the file after it's uploaded which I'm doing now.

Not sure how difficult this would be, but I think it would add a lot.

Thanks,
Matthew

error with rails generate......

Nathan -- I am following the tutorial, have made it to step 3, "rails generate....." here is the error that I am getting:

rails generate s3_swf_upload:uploader

Usage:
rails new APP_PATH [options]

Options:
-O, [--skip-active-record] # Skip Active Record files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-test-unit] # Skip Test::Unit files
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
-G, [--skip-git] # Skip Git ignores and keeps
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
[--edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-gemfile] # Don't create a Gemfile
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /usr/local/bin/ruby

Runtime options:
-s, [--skip] # Skip files that already exist
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Supress status output

Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit

Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.

Example:
rails new ~/Code/Ruby/weblog

This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.

rails version:

rails -v

Rails 3.0.1

Any ideas? This is an established app, just trying to update the uploader to something a little more useful :)

Thank you!
Jason

Exceptions raised inside methods called by ExternalInterface don't bubble into JS

When I have buggy code inside callbacks called by ExternalInterface, I never get any exceptions thrown in JS and all debugging gets really hard. I think it is because the AS code doesn't "marshalExceptions".

Please take a look at http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#marshallExceptions and http://code.google.com/p/swfupload/issues/detail?id=153

P.S. This is probably the real reason (bugs in handlers but no feedback) I couldn't get this plugin working before.

Thanks,

Jacek

Release as a gem

Now that this plugin has a gemspec and stuff, you should release it as a gem to rubygems.org. Then people can use it in their gemfiles directly, with just a gem 's3_swf_upload'.

Switching the 'Content-Disposition' to 'inline' cause a 403 error with Amazon.

Hi Nathan,

When left to it default setting in the S3UploadsController (line 30):

{'Content-Disposition': 'attachment'},

...uploads happen without a problem. If I switch to:

{'Content-Disposition': 'inline'},

...or remove the line completely in the hopes that by default my upload will be 'inline', Amazon returns with following error:

Amazon S3 returned an error: HTTP status 403.

Do I need to change something else in the controller?

Thanks,
Abel.

Longer Paperclip example?

Could you possibly elaborate on your paperclip example source? I'm new to Rails, and was able to get most of s3-swf-upload-plugin working, but I haven't been able to fully integrate it into my site yet.

Cant se files

Hi Nethan, I followed your tutorial to the letter,
please have a look at: http://furious-ocean-71.heroku.com/ as you can se there is no graphics for the files? I got the same issue on local host.

I'm running rails 3.0.0.
ruby 1.9.2 on localhost and 1.8.7 on heroku.

files are uploading OK from Heroku but not from localhost?

Cancel ongoing upload?

Hello,

Is there a way to cancel an ongoing upload? I used "s3_swf_1_object.removeFileFromQueue" but it didn't seem to work.

Thanks

Not working: Getting a "No method error"

Following your video on Vimeo, with the simplest configuration i get this error on my rails server:

NoMethodError (undefined method `&' for "v":String): app/controllers/s3_uploads_controller.rb:36:in `index'

And the line 36 in s3_uploads_controller.rb is the following:

signature = b64_hmac_sha1(secret_key, policy)

Please can you help me?

EDIT: Here's my Development.log file

NoMethodError (undefined method &' for "v":String): app/controllers/s3_uploads_controller.rb:36:inindex'

Rendered /Users/abramo/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /Users/abramo/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (35.3ms)
Rendered /Users/abramo/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (42.9ms)

Uploads bigger than 2 GB - redux

A little poking around in javascript showed at least some behavior around a 2 GB limit: When uploading a file that the filesystem reported as 2.9 Gb, the file size reported on the way into the uploader was 2971580103 - actually about 2.75 Gb. But who's counting.

The uploader hung for ever, and when progress events finally came back (I only got 2, and then it hung again), they reported a total byte count of 2147483647 - precisely 2 Gb, and only about 28k uploaded. Now, in a 32 bit system, an unsigned integer (what should be used for something like file size) is limited at 4 Gb. But a signed integer would be limited to 2 Gb. Perhaps there's a problem around the bit depth of flash?

To contrast, a much smaller file (< 1 Gb) hung a short while initially, but the upload was virtually instant, once it did begin.

Where to find "non-rails" version?

I use Rails on my personal projects (which is how I found out about this library). But now I need to integrate something like this in my PHP application. Is there a "standalone" version of this library that I can use in my PHP application?

Drag & Drop (HTML5)

I've just tested the gem and it worked great! The best solution I've found to upload directly to s3 using Rails and getting all the cool things such as upload progress, etc...

Is it possible to make a drag & drop work? Would JavaScript be able to tell Flash what file to upload? I guess this would be the flow as the file would be dropped into an HTML zone.

Anyway, I think we would have problems with Flash Security, right?

Thanks!

File Renaming

During my testes, I've uploaded a file called "apresentação.pdf" and it got renamed to "apresenta__o.pdf".

Then, I've uploaded the very same file through Amazon S3 console and the file wasn't renamed at all.

Reading the source, I couldn't find the code that renames a file. Does Flash, Rails or JS are doing this? Or the files get somehow renamed during the file transfer to S3 by Amazon itself?

Anyway I want to know if I can avoid the files being renamed automatically. Actually, I wouldn't want any renaming for now.

Thanks in advance

How to display Amazon Response XML?

I'm running into an error while trying to use this library that I am having trouble debugging. The onUploadIOError javascript callback method is being called, but the only thing that the io_error_event variable has is

text: "Amazon S3 returned an error: HTTP status 403."

I would like to debug further and inspect the XML response return from Amazon. I don't see a way to do that currently. Is there a way that we can pass a debug: true option to enable extra logging?

Multiple browse buttons not showing?

When I try to put more than one browse-button on a single webpage, only the last one is shown. The <object> tag is correctly inserted into the page, but Flash it self doesn't render it.

I'm on Chrome/Mac

signatureIOError "Error #2032" on Firefox 3.6 using Windows Vista

This only happens on this configuration of browsers while attempting to upload any video file to S3. From my research this is a Flash error that results from a bunch of different things such as cross-domain permissions, wrong file paths, etc. I cannot, however, find any of these issues with our application as this same script works just fine using any other browser/OS combo (even Firefox 3.6 on other OS')

Any insights into this, why this might happen, or anything else? I've been playing with this for hours now and just can't find anything useful...

How does this handle security?

I got this plugin working, it looks powerful and amazing. However, I'm trying to understand how secure it is. Why couldn't someone get to my /s3_uploads.xml, get a signature, and use it to upload files directly to S3, possibly overwriting other users' files?

Is there something I'm not understanding about how those signatures work? (i.e. that it only generates a valid signature if the request is coming from a swf file on the originating domain name).

No ability for the rails app to tell the uploaded what key name to give the new object

This is less an issue with this gem, and more an issue with S3's API, however we can work around it with a fix to the gem.

Basically, AWS's support for renaming/moving files is not what one might expect. Calling rename (at the very least, specifically with AWS::S3, as you do in one of your example gists) actually causes the object to transfered to and from S3. See the note here.

However, it's very common that we might want to upload a file to a temporary location, to prevent name collisions, for example. Additionally, the programmer might just want to be more specific than specifying a prefix for a key.

To allow this, the rails controller should have the ability to inspect the name of the file being uploaded, and generate the name of the S3 key that the file will become at will. It should generate the policy/signature based on this new key name, and then communicate back with the js/flex app, so that the file is uploaded to where it is authorized.

When multiple files are selected, the onQueueChanged handler is called multiple times

For example, if two files are selected, you first get a callback with the first file in the queue, and then you get a second call with both files in the queue.

While this doesn't matter much in the complex implementation example, where the queue is destroyed and recreated, it does in mine. I am trying to implement an uploader, similar to Gmail's, where the files start uploading immediately after they are selected. When having the onQueueChanged callback call startUploading(), the effect is that only the first file is uploaded.

Trigger the "browse files" button using Javascript?

Hi, I would like to integrate the plugin with my existing Javascript code, how can I force Javascript to click on the "browse files" button? Should I use Flux's ExternalInterface class? Which function should I look into?

Thank you!

Feature Request: Final File Name Configuration & keyPrefix

I have a case where I HAVE to have the final file name on S3 be a very specific name/format. We are using a version of this code from well over a year ago and the file name on S3 ends up just being the keyPrefix we set during initialization, however; after updating this code couple of days ago we noticed that the file name is now our keyPrefix PLUS the original file name appended to the end. For us this is not something that can be as we have a service that looks for a very specific file name format for our uploads.

I see in S3Signature.as, over a year ago, this snippet of code was touched:

  upload_options.key              = prefixPath + upload_options.FileName;

I am not positive this causes this issue, as I am not too familiar with this code, but it was my best find... Would it be possible to add an initialization option to NOT append the original file name to the end of the final file name?

I assume the version we were previously using, which made the keyPrefix the ENTIRE filename, was deemed to be a bug and changed to this, but we rely on it.

I also see that there is a part of the README now that tells people to do this with the back-end after the upload is complete, but that is super asynchronous, and somewhat kludgy as it can seemingly be done right from this bundle of code... (And, is being done already when the file is created on S3.)

Thanks!

-John

Graphic not showing up

I followed the great tutorial to the letter, and it looks right, but when I ad files they don't show up.

please have a look at: http://furious-ocean-71.heroku.com/ as you can se there is no graphics for the files? I got the same issue on local host.
I have uploaded a version of the demo project here http://sysx.dk/sites/default/files/swfuploader.zip

I'm running rails 3.0.0.
ruby 1.9.2 on localhost and 1.8.7 on heroku.

Files are uploading OK from Heroku but not from localhost?

Demo site not working?

Clicking on the "Browse" button brings up a file selection dialog box, and clicking "Start Uploading" makes the call to get the credentials, but no other traffic is occuring, nor any ui elements updating or otherwise indicating there's a transfer taking place. I had a packet tracer handy, and watched for traffic between my machine and.. well, anywhere meaningful.. and didn't see a single bit move around.

(osx10.5, FF, Chrome, and Safari, multiple machines, Flash 10.1)

I dunno, I thought maybe it was just something wrong in the demo, so I went step-for-step through the docs and the Vimeo vid (great to see that, BTW) and had the same exact behavior - credentials requested but no transfer. I reproduced this on team-mates laptop (10.6 etc etc)

Am I missing something? :(

Changing the Content Disposition Header

I'm having trouble changing one of the headers set in s3_uploads_controller.rb After making the change the upload no longer works.

Specifically line 30

{'Content-Disposition': 'attachment'},

to

{'Content-Disposition': 'attachment; filename=test.jpg'},

I want to see if it's possible to store the keys by their ID in the database rather than the filename, then when they are requested for download by paperclip use the original filename. The explanation can be found here.

Error using the generator

admins-MacBook-Pro-2:fsg_distro tamoyal$ rails generate s3_swf_upload:uploader /Users/tamoyal/.bundle/ruby/1.8/bundler/gems/s3-swf-upload-plugin-92ef46f0f8ea2918b3c41518bda8964dcdc26b78-master/lib/s3_swf_upload/s3_config.rb:14:in `load_config': You have a nil object when you didn't expect it! (NoMethodError) You might have expected an instance of Array. The error occurred while evaluating nil.[] from /Users/tamoyal/.bundle/ruby/1.8/bundler/gems/s3-swf-upload-plugin-92ef46f0f8ea2918b3c41518bda8964dcdc26b78-master/lib/s3_swf_upload/railtie.rb:8 from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/initializable.rb:25:in`instance_exec' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/initializable.rb:25:in `run' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/initializable.rb:55:in`run_initializers' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/initializable.rb:54:in `each' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/initializable.rb:54:in`run_initializers' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:119:in `initialize!' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:81:in`send' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:81:in `method_missing' from /Users/tamoyal/Projects/fsg_distro/config/environment.rb:5 from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:94:in`require' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:94:in `require_environment!' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:81:in`send' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/application.rb:81:in `method_missing' from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands.rb:16 from script/rails:6:in`require' from script/rails:6

Demo not working?

Not sure if it is both of my setups, mac and pc.... but All of a sudden, my s3-swf stopped working... I checked your demo... it deosn't appear to be working either... Is this just me?

NoMethodError in S3UploadsController#index undefined method `&' for "a":String

Followed the steps in the README, but the S3UploadsController throws that error.

Here's the full trace:

/Users/andrewculver/.rvm/gems/ruby-1.9.2-p180@ll/bundler/gems/s3-swf-upload-plugin-6713b1785d6e/lib/s3_swf_upload/signature.rb:146:in `str2binb'
/Users/andrewculver/.rvm/gems/ruby-1.9.2-p180@ll/bundler/gems/s3-swf-upload-plugin-6713b1785d6e/lib/s3_swf_upload/signature.rb:105:in `core_hmac_sha1'
/Users/andrewculver/.rvm/gems/ruby-1.9.2-p180@ll/bundler/gems/s3-swf-upload-plugin-6713b1785d6e/lib/s3_swf_upload/signature.rb:12:in `b64_hmac_sha1'
app/controllers/s3_uploads_controller.rb:36:in `index'
actionpack (3.0.9) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.9) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.9) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.9) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.9) lib/active_support/callbacks.rb:451:in `_run__295166068075221059__process_action__4528472676961896999__callbacks'
activesupport (3.0.9) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.9) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.9) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.9) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.9) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.9) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.9) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.9) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.9) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.9) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.9) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.9) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.9) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:493:in `call'
sass (3.1.3) lib/sass/plugin/rack.rb:54:in `call'
warden (1.0.4) lib/warden/manager.rb:35:in `block in call'
warden (1.0.4) lib/warden/manager.rb:34:in `catch'
warden (1.0.4) lib/warden/manager.rb:34:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.9) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.9) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.9) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.9) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.9) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.9) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.9) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.9) lib/rails/application.rb:168:in `call'
railties (3.0.9) lib/rails/application.rb:77:in `method_missing'
railties (3.0.9) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.3) lib/rack/content_length.rb:13:in `call'
rack (1.2.3) lib/rack/handler/webrick.rb:52:in `service'
/Users/andrewculver/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/andrewculver/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/andrewculver/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

Ie8 / windows xp

Hi Nathan,
It looks like there's some bugs on windows XP with IE8 or IE7.
The browse button appears but selecting a file doesn't trigger the "onFileAdd" or "onQueueChange" events.
I thought first it was caused by me but it appears than the demo at s3swfupload.heroku.com doesn't work.
I'm trying to find out why now but if you got an idea ...
I'll let you know if I find something,

Thanks.

Doesn't load in Firefox when using a modal dialog box

Hi, when using this plugin, FireFox does not insert the flash into my html. I do not get eny errors or warnings from the error console, but all that is left in my HTML is a hidden div like this:

<div id="s3_swf_1">
  Please <a href="http://www.adobe.com/go/getflashplayer">Update</a> your Flash Player to Flash v9.0.0 or higher...
</div>

Any idea why this is? What can I do to provide better debugging information and/or resolve this?

  • Jeppe

undefined method "&" for "K":String

using ruby 1.9.2 and rails 3, line 36 of the s3_upload controller would output the error message...

undefined method "&" for "K":String

that made no sense to me, but it must have something to do with the signature file and the method "b64_hmac_sha1"... however i found this snippet in amazon s3 docs that got it working for me...

signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, policy)).gsub("\n","")

i've seen similar errors in ruby 1.9 due to a change in the way strings are encoded. just a FYI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.