Git Product home page Git Product logo

Comments (6)

LuchoTurtle avatar LuchoTurtle commented on July 3, 2024 1

Because the current code used in the LiveView make the upload from Javascript (followed by the File Upload guide in https://hexdocs.pm/phoenix_live_view/uploads.html), because it's been requested that the LiveView uses the upload/1 function that was implemented, I'm going to create a new page to use LiveView but use this function. I'm not going to refactor the code of the pre-existing LiveView because it would essentially be overhauled.

In order to not lose the previous work made, I'm going to create a new page that is "clientless", which uses the upload/1 function that was implemented.

from imgup.

LuchoTurtle avatar LuchoTurtle commented on July 3, 2024 1

The closed PR #64 directly addresses this. It generates the CID from the contents of the file within the JS code.
Because using JS to push the file was not initially intended, I closed off the PR. If relevant, I might open it back up again to finish it.

from imgup.

LuchoTurtle avatar LuchoTurtle commented on July 3, 2024 1

And yes, I'm doing the "clientless" version now on a different live view page. I want to get this done before doing other issues (like the image classifier) so I can have a more solid foundation to work on it.

I'm branching off from #86 (review) so I don't have merge conflicts later on 👌

from imgup.

LuchoTurtle avatar LuchoTurtle commented on July 3, 2024

With the changes introduced in

imgup/lib/app/upload.ex

Lines 22 to 27 in 2f51c88

def upload(image) do
# Create `CID` from file contents so filenames are unique
#
{:ok, file_binary} = File.read(image.path)
file_cid = Cid.cid(file_binary)
file_name = "#{file_cid}.#{Enum.at(MIME.extensions(image.content_type), 0)}"
, I believe this issue is no longer relevant and should be closed.

from imgup.

nelsonic avatar nelsonic commented on July 3, 2024

The upload.ex is only used for the API.

from imgup.

nelsonic avatar nelsonic commented on July 3, 2024

Indeed the guide written by Chris https://github.com/phoenixframework/phoenix_live_view/blob/v0.19.3/guides/server/uploads.md#L1 uses the JS "direct" uploads method with signing. That is preferable in certain circumstances. If we can read the contents of the file on the device/browser we could use the JS implementation of CID to create the filename and thus continue using the direct upload approach. But I find that it requires considerably more code and isn't well tested. 💭

If you end up making a "clientless" version that uses the upload/1 function, please document + test as much as possible. 🙏

from imgup.

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.