Skip to content

Commit

Permalink
Update plugin based on use in latest project.
Browse files Browse the repository at this point in the history
Fix the params to specify allowed file types.
Make the background transparent by default, more useful to other projects that way.
Shorten column names and labels to be shorter, so overall width can be reduced.
Fix readme with accurate example code.
  • Loading branch information
kookster committed Apr 19, 2010
1 parent e6b9525 commit e3640df
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
34 changes: 19 additions & 15 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,29 @@ Usage

7. If you want to customize its behavior, here's a more complex example:

<%= s3_swf_upload_tag(
:width => 550,
:height => 175,
:success => "jQuery.post('/file_upload', {'uuid':'#{@uuid}',
'filename':filename,
'filesize':filesize,
'contenttype':contenttype},
null, 'script');",
:failed => 'alert("Failed: " + status);',
:prefix => "prefix_in_bucket/#{@uuid}",
:initial_message=> 'Click "Browse..." to find files to upload.')
<%= raw s3_swf_upload_tag(
:width => 390,
:height => 150,
:file_types=>'*.jpg;*.gif;*.png;',
:file_type_descriptions =>"Image files.",
:success => "$.post('/attachments.js',{'filename':filename,
'filesize':filesize,
'content_type':contenttype,
'authenticity_token':'#{form_authenticity_token}'},
null, 'script');",
:failed => 'alert("failed: " + status);',
:info => '$("#upload-messages").html(status);',
:prefix => "public/attachment",
:initial_message=> 'Click "Browse..." to find files to upload.')
%>
</div>
<div id="upload-messages" name="upload-messages" class="notice"></div>


In this case, files will be uploaded to:
http://bucket.s3.amazonasw.com/prefix_in_bucket/uuid_value
and when successful, will post the information about the file uploaded, including this UUID, to the file_upload controller.

http://bucket.s3.amazonasw.com/public/attachment
and when successful, will post the information about the file uploaded to the attachments controller as a json post using JQuery.

Original plugin is Copyright (c) 2008 elctech, released under the MIT license

Updates to plugin Copyright (c) 2010 PRX, released under the MIT license
Updates to plugin for multiple file uploader are Copyright (c) 2010 PRX, released under the MIT license
2 changes: 1 addition & 1 deletion flex_src/src/S3Uploader.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<mx:Script source="S3Uploader.as"/>

<mx:VBox width="550" height="175">
<mx:VBox width="385" height="150">

<mx:DataGrid id="filesDataGrid"
left="0"
Expand Down
11 changes: 6 additions & 5 deletions flex_src/src/org/prx/uploader/MultipleFileS3Uploader.as
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ package org.prx.uploader {
_fileFilter = new FileFilter(fileTypeDescs, fileTypes);
_maxFileSize = parseInt(maxFileSize);
_dateTimeFormatter = new DateFormatter();
_dateTimeFormatter.formatString = "MM/DD/YYYY L:NN A";
/*_dateTimeFormatter.formatString = "MM/DD/YYYY L:NN A";*/
_dateTimeFormatter.formatString = "MM/DD/YY";
_totalbytes = 0;

// js callback functions
Expand Down Expand Up @@ -142,14 +143,14 @@ package org.prx.uploader {
_nameColumn.headerText= "File";

_sizeColumn.dataField = "size";
_sizeColumn.headerText = "File Size";
_sizeColumn.headerText = "Size";
_sizeColumn.labelFunction = bytesColumnToString as Function;
_sizeColumn.width = 60;
_sizeColumn.width = 52;

_updatedColumn.dataField = "modificationDate";
_updatedColumn.headerText = "Date Modified";
_updatedColumn.headerText = "Modified";
_updatedColumn.labelFunction = dateTimeColumnToString as Function;
_updatedColumn.width = 150;
_updatedColumn.width = 64;

_columns = new Array(_nameColumn, _sizeColumn, _updatedColumn);
_filesDataGrid.columns = _columns
Expand Down
Binary file modified generators/s3_swf_upload/templates/s3_upload.swf
Binary file not shown.
10 changes: 6 additions & 4 deletions lib/s3_swf_upload/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def s3_swf_upload_tag(options = {})
prefix = options[:prefix] || ''
upload = options[:upload] || 'Upload'
initial_message = options[:initial_message] || 'Select file to upload...'
max_file_size = options[:maxFileSize] || '524288000'
file_types = options[:fileTypes] || "*.*"
file_type_descriptions = options[:fileTypeDescs] || "All Files"
max_file_size = options[:max_file_size] || '524288000'
file_types = options[:file_types] || "*.*"
file_type_descriptions = options[:file_type_descriptions] || "All Files"

prefix = prefix + "/" unless prefix == ""

Expand All @@ -30,9 +30,11 @@ def s3_swf_upload_tag(options = {})
out << %(<a name="uploadform#{@count}"></a>
<script type="text/javascript">
var s3_swf#{@count} = s3_swf_init('s3_swf#{@count}', {
wmode:, "transparent",
wmode: 'transparent',
width: #{width},
height: #{height},
fileTypes: '#{file_types}',
fileTypeDescs: '#{file_type_descriptions}',
initialMessage: '#{initial_message}',
prefix: '#{prefix}',
onSuccess: function(filename, filesize, contenttype){
Expand Down

0 comments on commit e3640df

Please sign in to comment.