Permalink
Browse files

merge and update

  • Loading branch information...
1 parent b3432fb commit 07fd966e23eea4e1ead40bff034475230cc0bf28 @lgn21st lgn21st committed Nov 17, 2008
Showing with 18 additions and 38 deletions.
  1. +16 −7 generators/s3_swf_upload/templates/controller.rb
  2. +2 −31 lib/s3_swf_upload/view_helpers.rb
@@ -8,12 +8,14 @@ def index
end
def create
- expiration_date = params[:expiration_date]
- bucket = params[:bucket]
- acl = params[:acl]
- content_type = params[:content_type]
+ bucket = S3SwfUpload::S3Config.bucket
+ access_key_id = S3SwfUpload::S3Config.access_key_id
key = params[:key]
+ content_type = params[:content_type]
file_size = params[:file_size]
+ acl = 'private'
+ https = 'false'
+ expiration_date = 1.hours.from_now.strftime('%Y-%m-%dT%H:%M:%S.000Z')
policy = Base64.encode64(
"{
@@ -32,9 +34,16 @@ def create
respond_to do |format|
format.xml {
- render :xml => {:policy => policy,
- :signature => signature}.to_xml
+ render :xml => {
+ :policy => policy,
+ :signature => signature,
+ :bucket => bucket,
+ :accesskeyid => access_key_id,
+ :acl => acl,
+ :expirationdate => expiration_date,
+ :https => https
+ }.to_xml
}
end
end
-end
+end
@@ -17,41 +17,12 @@ def s3_swf_upload_tag(options = {})
end
def js_s3_swf_upload_init(options={})
- bucket = options[:bucket] || S3SwfUpload::S3Config.bucket
- access_key_id = options[:access_key_id] || S3SwfUpload::S3Config.access_key_id
- expiration = options[:expiration] || 1.hours.from_now.strftime('%Y-%m-%dT%H:%M:%S.000Z')
signature_url = options[:signature_url] || s3_signatures_url
- https = options[:https] || 'false'
- acl = options[:acl] || 'private'
-
%(
<script language="JavaScript" type="text/javascript">
<!--
- // -------------------------------- //
- // initial function for S3SWFUpload //
- // -------------------------------- //
function initS3SWFUpload() {
- document["S3SWFUpload"].initS3SWFUpload(
- "#{access_key_id}", //AWSAccessKeyId
- "#{bucket}", //bucket
- "#{https}", //Secure (Use HTTPS, true or false)
- "#{expiration}", //Expires
- "#{acl}", //acl
- "#{signature_url}"); //SignatureQueryURL
- }
- // -->
- </script>
- )
- end
-
- def js_s3_swf_upload_complete
- %(
- <script language="JavaScript" type="text/javascript">
- <!--
- // -------------------------------- //
- // S3SWFUpload Complete Callback //
- // -------------------------------- //
- function S3SWFUploadComplete(key) {
+ document["S3SWFUpload"].initS3SWFUpload("#{signature_url}");
}
// -->
</script>
@@ -60,4 +31,4 @@ def js_s3_swf_upload_complete
end
end
-ActionView::Base.send(:include, S3SwfUpload::ViewHelpers)
+ActionView::Base.send(:include, S3SwfUpload::ViewHelpers)

0 comments on commit 07fd966

Please sign in to comment.