keichan34 / exfile

File upload persistence and processing for Phoenix / Plug
MIT License
90 stars 19 forks source link

When add file extension to filename, processing using convert failed with reason no_processor #49

Open loongmxbt opened 8 years ago

loongmxbt commented 8 years ago
<%= exfile_path(@paper.file, filename: "PID#{@paper.id}-CID#{@topic.id}") %>
# URI
http://localhost:4000/attachments/f_LMR2YRJf7VRSrYEuKSmIYP0SXDilBiesY7lbhJqWY=/store/d907666bb877f897119308dfaa65cb96a6f827f6e089cb498bf7290548da/PID1-CID1

works fine.

But when add .pdf or other file extensions

<%= exfile_path(@paper.file, filename: "PID#{@paper.id}-CID#{@topic.id}.pdf") %>
# URI
http://localhost:4000/attachments/TpZXUPYiDwdC5B3S75Ju9aF1pFPM3iby8sHGE6X_ngE=/store/d907666bb877f897119308dfaa65cb96a6f827f6e089cb498bf7290548da/PID1-CID1.pdf

It shows

processing using convert failed with reason no_processor

Any ideas how to add extension for download?

PS:

If I use format: "pdf", seems nothing changes.

Press CTRL+S the filename still have no extension like PID1-CID1
# URI
http://localhost:4000/attachments/f_LMR2YRJf7VRSrYEuKSmIYP0SXDilBiesY7lbhJqWY=/store/d907666bb877f897119308dfaa65cb96a6f827f6e089cb498bf7290548da/PID1-CID1
loongmxbt commented 7 years ago

Using exfile-imagemagick and imagemagick solves the "file rename problem".

scarfacedeb commented 6 years ago

I have a similar issue.

I'm serving .pdf files and identify -format %w <file> commands takes too long to run, giving me GenServer Timeout error. (I'm using master branch of ExfileImagemagick)

I compared the source code of refile and exfile and noticed that refile skips the file conversion when there's no processor in the url. Conversely, exfile always tries to convert the file when format is present in the url.

@keichan34 what do you think about adding the whitelist of extensions that support format conversion?

It could process all of the formats by default to keep backwards compatibility.

scarfacedeb commented 6 years ago

@keichan34 I've updated my fork of exfile to support whitelisted formats.

If you're interested, here's the relevant commit: https://github.com/scarfacedeb/exfile/commit/6d1b0d26136cf7d9786402b93230a32c3c245a2d