GithubHelp home page GithubHelp logo

Direct uploads? about arc HOT 10 OPEN

stavro avatar stavro commented on August 16, 2024 1
Direct uploads?

from arc.

Comments (10)

stavro avatar stavro commented on August 16, 2024 3

I assume you mean "Browser Uploads to S3" directly (rather than going through your webserver), as outlined here.

Right now arc does not facilitate this.

Let me think a bit about how an integration might look and if including it in this package vs a separate package would be best.

Thanks for your input!

from arc.

stavro avatar stavro commented on August 16, 2024 1

I have not started on this feature, and I likely won't have time to for a little while.

But I am open to including some of the core functionality in this package.

Namely:

  • A straightforward way of generating the policy, signature, etc.
  • A way to consume the uploaded file and run transformations.

In my head a workflow would look something like:

  1. Server creates an upload form using policy, signature, etc from Arc.
  2. Client uploads file directly to S3.
  3. Upon successful upload, client informs server that the upload has finished.
  4. Server instructs Arc to process transformations of the newly uploaded file.

I believe ExAws has all of the necessary logic to do this.

from arc.

terencechow avatar terencechow commented on August 16, 2024

Does this support using an http url instead of a file path to upload an image directly to s3?

from arc.

stavro avatar stavro commented on August 16, 2024

@Chowza I have a branch open which does this: #7

I haven't merged it since I'm not actually using it in production yet, and I might want to change it to be a little more explicit about remote vs. local retrieval. But you're welcome to try it and let me know your thoughts!

from arc.

gordonbisnor avatar gordonbisnor commented on August 16, 2024

Do you think the remote-files branch work with arc_ecto? Anything special required to make it work?

I am attempting to build a seed file... in mix.exs I have:

{:arc, git: "https://github.com/stavro/arc.git", branch: "remote-files", override: true},

And in my seed file:

path = ~s(http://www.isnorcreative.com/system/images/#{image.id}/original/#{image.file})
changeset = Gbiphoenix.ProjectImage.changeset(%Gbiphoenix.ProjectImage{}, %{project_id: project.id, image: path} )
Gbiphoenix.Repo.insert!(changeset)

I am getting a changeset error:

[image: "can't be blank"]

I have been looking poking around in arc and arc_ecto seeing if arc_ecto would need to be modified to make this work, but have yet to figure it out.

from arc.

stavro avatar stavro commented on August 16, 2024

@gordonbisnor Can I see your model and the changeset function you have defined?

from arc.

gordonbisnor avatar gordonbisnor commented on August 16, 2024

Yes this is it here:

defmodule Gbiphoenix.ProjectImage do
  use Gbiphoenix.Web, :model
  use Arc.Ecto.Model

  schema "project_images" do
    field :image, Gbiphoenix.Image.Type
    belongs_to :project, Gbiphoenix.Project
    timestamps
  end

  @required_fields ~w(project_id)
  @optional_fields ~w()

  @required_file_fields ~w(image)
  @optional_file_fields ~w()

  @doc """
  Creates a changeset based on the `model` and `params`.

  If no params are provided, an invalid changeset is returned
  with no validation performed.
  """
  def changeset(model, params \\ :empty) do
    model
    |> cast(params, @required_fields, @optional_fields)
    |> cast_attachments(params, @required_file_fields, @optional_file_fields)
  end
end

from arc.

gordonbisnor avatar gordonbisnor commented on August 16, 2024

@stavro It seems that my seed file is specifying params with atom keys rather than string keys, which then causes the Dict.take function to return empty as it is comparing the binary lists of ~w() optional_file_fields and required_file_fields with the atoms of my seed file params.

I have an arc-ecto fork with a remote-files branch where I convert the required ++ optional list to atoms which worked for me. I didn't do a pull request because I don't know exactly what's going on here – I'm new to Elixir. I also found that I needed to convert the maps in the model test file to use atom keys as well, I was getting 4 failing tests with string keys.

Now that I think of it, I must have created the broken tests in my fork by converting the keys to atoms.

from arc.

Lazarus404 avatar Lazarus404 commented on August 16, 2024

@stavro did you get the uploads pass-thru working? Is this a feature yet of Arc? If not, did you create a separate package providing this? I'd like to facilitate pass-thru upload and download of files.

Thanks

from arc.

simonh1000 avatar simonh1000 commented on August 16, 2024

Me too for pass-through - what is the status. It looks as the S3 libraries come with some sort of signing function (e.g. for node) which needs to be emulated? This code might already do it http://jhosteny.github.io/2015/06/10/elixir-clojurescript-s3-upload/

from arc.

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.