PDF upload and display


File upload (jpeg,png) ok., but how to upload and display pdf files with phoenix…
Anyone a link/tut? Cant find anything…

Thanks for support.

Why would PDF handling be unique? What issue are you having?

1 Like

Imagemagick’s convert (e.g. used via mogrify) can produce thumbnails from PDF files. Make sure to tell it to only use the first page or else you’ll end up with a thumbnail for every page

Well, pdf != image
I get : {:error, :invalid_file}
When I take a png …it works

I have a lib/storage/uploaders/file.ex

  defmodule MyApp.File do
  use Arc.Definition
  use Arc.Ecto.Definition

  def __storage, do: Arc.Storage.Local
  @versions :original

and a lib/…web/uploaders/pdf_uploader.ex

defmodule MaApp.PdfUploader do
  use Arc.Definition

  @versions [:original]

May be later I can convert with mini-magick etc., but right now the pdf is not accepted…

I haven’t used Arc but are you sure “pdf” is one of your whitelisted
file extensions?

made it white:

def validate({file, _}) do
  ~w(.pdf) |> Enum.member?(Path.extname(file.file_name))

so far I managed an upload and my show action shows: