Update. [not sure if this was introduced in Rails 7 or before] Instead of hardcoding the URL in the postURL method, it is possible to use the direct_upload: true in the file field and retrieve its value calling this.inputTarget.dataset.directUploadUrl
☒ I'm not sure the token is still required in Rails 7.0.2 I was building an app few days ago and found out that you can remove it... Also, if planning to use it it seems that you can write const token = event.target.dataset.directUploadToken; inside the stimulus controller (Rails 7 required) and avoid writing an helper method to generate the token and declaring it in the form.
nelsonchavespro I do not think so. From what I found out, you have to implement this logic in a Stimulus controller. There is an example from DHH in a comment about this feature request in GitHub. Here is a thread about this topic on Reddit with all the links I found: https://www.reddit.com/r/rails/comments/vntbl3/best_way_to_deal_with_sorted_data_in_a_stream/ feel free to contradict me if you find a better way. Cheers