stavro/arc_ecto

Allow storage of based on external URLs?

Closed this issue · 2 comments

@stavro

Is it possible to add an option to store the image based on an external URL, filename and scope? Def.store(%{filename: '....', path: 'blob:http://localhost:4000/sdfsfsfd.jpg'}, my_scope)

Currently even though there's a pattern match to accept this, it doesn't work because it uses File.exists? to check if the file is temp stored in Phoenix. Which this file isn't, so this returns an error, even though the URL is technically still valid:

  def new(%{filename: filename, path: path}) do
    case File.exists?(path) do
      true -> %Arc.File{path: path, file_name: filename}
      false -> {:error, :invalid_file_path}
    end
  end

I'd love to have support for storing images based on external source URL and a filename. This would be a huge convenience because users will no longer need to send FormData in order to generate the Plug.Upload struct.

PS. Thanks for the amazing library!

This is in master of Arc.

Def.store({"https://google.com/favicon.ico", scope})

You can't pass blob urls around though - if that url is generated during a browser session then it won't be accessible anywhere else.