-
-
Save boy-jer/4555031 to your computer and use it in GitHub Desktop.
Using plupload with emberjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Forms.ImageUploader = Ember.View.extend | |
classNames: ['ember-image-uploader'] | |
controller: null | |
didInsertElement: -> | |
controller = @get('controller') | |
if controller.get('imageUploadUrl') | |
@initUploader() | |
else | |
@get('controller').addObserver 'imageUploadUrl', => | |
if @get('controller.imageUploadUrl') | |
@get('controller').removeObserver('imageUploadUrl') | |
@initUploader() | |
initUploader: -> | |
controller = @get('controller') | |
@$().pluploadQueue | |
runtimes: "html5, html4, flash, silverlight" | |
url: controller.get('imageUploadUrl') | |
max_file_size: "10mb" | |
# chunk_size: "1mb" | |
unique_names: true | |
browse_button: 'Add files' | |
multipart: true | |
multipart_params: | |
'authenticity_token' : App.Helpers.getCSRFToken() | |
filters: | |
[ | |
title: "Image files" | |
extensions: "jpg,gif,png,jpeg" | |
] | |
flash_swf_url: "/assets/plupload/plupload.flash.swf" | |
silverlight_xap_url: "/assets/plupload/plupload.silverlight.xap" | |
init: | |
FileUploaded: (upload, file, info) -> | |
controller.imageUploaded(upload, file, info) | |
Error: (upload, args) -> | |
throw { | |
type: "Upload Error" | |
upload: upload | |
arguments: args | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment