Giter Club home page Giter Club logo

Comments (10)

posgarou avatar posgarou commented on August 29, 2024 2

@MartinElvar I've found two things that work now:

(1) Pipe the path through Path.relative_to:

def logo_url(company) do
  Mobil.Logo.url({company.logo, company}, :thumb)
  |> Path.relative_to("priv/static")
end

(2) Or go with the default uploads directory and specify in lib/{your_app}/endpoint.ex, underneath the first plug Plug.Static, a second plug Plug.Static to serve static assets from the upload directory:

  plug Plug.Static,
    at: "/uploads", from: Path.expand('./uploads'), gzip: false

Fair warning: I've only been using LocalStorage for sample apps and am using S3 for anything larger than that.

from arc_ecto.

t56k avatar t56k commented on August 29, 2024 1

@posgarou Thanks for the hints, (2) worked for me but only after modifying the default plug like so:

plug Plug.Static,
  at: "/", from: :panda, gzip: false, 
  only: ~w(css fonts images js effort_csvs favicon.ico robots.txt)

Here effort_csvs is my upload folder. Then I had to write a helper to replace the priv/static as you might imagine. I explained my answer in more detail here: http://stackoverflow.com/a/38690793/1342734

from arc_ecto.

stavro avatar stavro commented on August 29, 2024

Thanks - Let me think about this.

I personally don't use local storage as the apps I'm building are scaled across multiple machines - but this is something I would like to support.

from arc_ecto.

MartinElvar avatar MartinElvar commented on August 29, 2024

@posgarou Thank you for your feedback, i actually ended up creating this lille helper.

  def correct_image_path(path) do
    String.replace path, "priv/static/", "/"
  end

I love your suggestions tho, specially #2, maybe we should add this to the documentation @stavro? 😄

from arc_ecto.

bratsche avatar bratsche commented on August 29, 2024

Thanks @posgarou, this was very helpful! I used (2) and it worked very well.

from arc_ecto.

posgarou avatar posgarou commented on August 29, 2024

@bratsche Glad to hear it helped!

from arc_ecto.

uldza avatar uldza commented on August 29, 2024

Kudos to @posgarou second suggestion works great!

from arc_ecto.

Fadhil avatar Fadhil commented on August 29, 2024

@posgarou I did something similar to what @MartinElvar did, and it worked great on development. But when I made a release with exrm and deployed the compiled app (let's say to /apps/my-app/), uploading a file would then upload to a dir at /apps/my-app/uploads/, which isn't accessible from the compiled app, since it only looks in `priv/static. Has anyone had success with an exrm release and storing files locally?

from arc_ecto.

smithaitufe avatar smithaitufe commented on August 29, 2024

@posgarou
I used this option
plug Plug.Static,
at: "/uploads", from: Path.expand('./uploads'), gzip: false

This shows the images in the index page. But the problem is when I try to view a single record in the show action, it doesn't work. Looking at the path generated for the image, it adds the name of the model to the path. Please has anyone encountered this before?

from arc_ecto.

sebastialonso avatar sebastialonso commented on August 29, 2024

@cd-rum Yes! This helped. It seems that if you're using a folder within priv/static to store yout assets, you need to add that folder to the original list (attachments in my case)

plug Plug.Static,
    at: "/", from: :properties, gzip: false,
    only: ~w(css fonts images attachments js favicon.ico robots.txt)

from arc_ecto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.