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

Waffle.Actions.Store.store does not include storage_dir config value (Waffle.Storage.Local) #98

Open
bumbus opened this issue May 12, 2022 · 2 comments

Comments

@bumbus
Copy link

bumbus commented May 12, 2022

Environment

Erlang/OTP 23 [erts-11.1.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe]
Elixir 1.12.3 (compiled with Erlang/OTP 22)

waffle 1.1.5
waffle_ecto 0.0.11

Issue

I am not sure if this is an actual bug or I misunderstand the role of storage_dir config.
Round about I have the following code:

config :waffle,
  storage: Waffle.Storage.Local,
  asset_host: "",
  storage_dir: "storage"
defmodule Storage.ProfileFile do
  use Waffle.Definition
  use Waffle.Ecto.Definition

  @versions [:original]

  def storage_dir(_version, {_file, profile}) do
    "profiles/#{profile.id}"
  end
end
  Storage.ProfileFile.store({
    %Plug.Upload{
      filename: file_name,
      path: meta.path
    },
    %{id: profile_file.profile_id}
  })

Expected behavior

I would expect the newly uploaded file is saved in storage/profiles/<SOME_ID>/FILENAME.EXT

Actual behavior

The newly uploaded file is actually saved in profiles/<SOME_ID>/FILENAME.EXT

@bumbus
Copy link
Author

bumbus commented May 12, 2022

Ok the upload destination works with the following config:

config :waffle,
  storage: Waffle.Storage.Local,
  asset_host: "",
  # storage_dir: "storage"
  storage_dir_prefix: "storage"

But: Storage.ProfileFile.url({file_name, profile}) omits the storage_dir_prefix value.

@achempion
Copy link
Member

achempion commented May 12, 2022 via email

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

2 participants