valkyrie icon indicating copy to clipboard operation
valkyrie copied to clipboard

Storage adapters should have #id_for

Open tpendragon opened this issue 4 years ago • 2 comments

This should take the same parameters as #upload, but just return the ID that it would build when it's done.

Useful when you're not storing the resulting ID, and need to re-calculate it so you can find the file again.

tpendragon avatar Dec 17 '21 19:12 tpendragon

would this just be #upload but with the file moving removed? so something like

    def id_for(file:, original_filename:, resource: nil, **_extra_arguments)
      new_path = path_generator.generate(resource: resource, file: file, original_filename: original_filename)
      # FileUtils.mkdir_p(new_path.parent)
      # file_mover.call(file.path, new_path)
      # find_by(id: Valkyrie::ID.new("disk://#{new_path}"))
      Valkyrie::ID.new("disk://#{new_path}")
    end

dunn avatar Oct 19 '22 22:10 dunn

Yeah that makes sense to me.

tpendragon avatar Oct 19 '22 23:10 tpendragon