Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access file/file path in changeset #65

Open
pejrich opened this issue Feb 11, 2017 · 2 comments
Open

Can't access file/file path in changeset #65

pejrich opened this issue Feb 11, 2017 · 2 comments

Comments

@pejrich
Copy link

pejrich commented Feb 11, 2017

What's the point of the cast_attatchements helper? I want to be able to do some stuff with the file in my changeset. Right now, purely by having my schema as field :picture, Pykture.PictureUploader.Type, it causes the changeset the process the upload to S3, and covert my :changes field in my changeset to a %{file_name: "name.jpg", updated_at: XXX}. I would have have params like: %{picture: "/some/path/name.jpg"}. I want to be able to use /some/path/name.jpg BEFORE I decide the upload the process my file, I thought that was what cast_attatchements did, and I could therefore process/upload my file at a later point in my changeset sequence. Is there anyway to do this? Right now there seems to be no difference between having cast_attatchements and not having it. Either way, my changeset will immediately upload/process my file, and convert the file to use the customize map.

@lessless
Copy link

lessless commented Mar 9, 2017

I believe this is pretty much not directly related to the arc_ecto. Handling uploads with directly with Plug.Upload will give the desired flexibility to manipulate resources before pushing them to S3.

@andreapavoni
Copy link

@pejrich if you want custom paths, you need to work on your uploader file and override storage_dir function. Unfortunately you can't use the model's id because it's not available when you create a new record (except the case you're adding a file after the record is already created).
If you need to apply some algorithm to generate the desired path, then you have to work on the changeset before cast_attachments is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants