uploadcare / uploadcare-rails

Rails API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
MIT License
58 stars 70 forks source link

Set data-multiple on field helper #119

Closed jjf21 closed 1 year ago

jjf21 commented 1 year ago

Brief description of the feature and motivation behind it

Hey, it would be nice to be able to pass the multiple: false to the field helper, to force the single/multiple files select, rather than depend on the attribute name

Might be nice that options[:multiple] has priority on uploadcare_uploader_multiple? here: https://github.com/uploadcare/uploadcare-rails/blob/main/lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb#L31

What do you think?

kraft001 commented 1 year ago

@jjf21 Thank you for the idea! The feature was added to the new version 3.3.1. Please, try it

jjf21 commented 1 year ago

Hello @kraft001, thanks it's working perfectly ! 👌

jjf21 commented 1 year ago

@kraft001 Unfortunatly we have a problem.

The mount_uploadcare_file_group.rb is using theGROUP_ID_REGEX to set a the group_id, but it's not matching. While single file does not match this regex. It should use the default regex in IdExtractor => /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/

Resulting in

Uploadcare::Exception::RequestError
group_id is required.
kraft001 commented 1 year ago

@jjf21 Thank you for the bug report! The issue seems to be unrelated to the suggested feature (options[:multiple]), it would be great to create a new Github issue. I'm not sure how I can replicate the error Uploadcare::Exception::RequestError group_id is required., could you describe the steps you took?