Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where can I specify allowed file types? #13

Closed
jocubeit opened this issue Jun 22, 2010 · 2 comments
Closed

Where can I specify allowed file types? #13

jocubeit opened this issue Jun 22, 2010 · 2 comments

Comments

@jocubeit
Copy link

I have a ticket model which will permit asset uploads (PDF, ZIP, DOC, XLS, etc). I do not have a model for the attachment.

class Ticket < ActiveRecord::Base
  papermill :attachments
end

I have the following line in config/initializers/papermill.rb:

:images_only => false,

I get the following growl feedback after the file has transferred:

36341.DOC
File is not one of the allowed file types.

I'm just wondering where I can explicitly permit certain extensions, or content types without having an attachment model?

@jocubeit
Copy link
Author

I modified the set_papermill_inline_js method in form_builder.rb to get this to work. I changed the following line from:

file_types: "#{ options[:images_only] ? '*.jpg;*.jpeg;*.png;*.gif' : '' }",

to:

file_types: "#{ options[:images_only] ? '*.jpg;*.jpeg;*.png;*.gif' : '*.*' }",

It now works just fine.

I'm on a Mac, so not sure if this was an OSX specific issue or not. Let me know if there is some other way I should have fixed this - perhaps a config setting that I missed.

@bbenezech
Copy link
Owner

I just investigated this. Seems like a design bug, the error you get has nothing to do with SwfUpload and the file_types settings (who just set constraints on the file browser).
The problem lies with Paperclip, who doesn't support inherited settings.
The ImageAsset < PapermillAsset Paperclip validation creeped the superclass (PapermillAsset) validation. (at least for the demo)
Basically, looks like you can only have only one asset class used with Papermill :/

If you don't need the server side validation and can go with SwfUpload filters, you can just use :images_only or :swfupload => { :file_types => ".jpg;.xls" } for a narrower filtering.

I've included your fix anyway, maybe there is a SwfUpload side effect in your case?

Released in next gem within a few hours.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants