Referencing this PR: Allow providing a custom key per blob · rails/rails@4dba136 · GitHub
We can now specify a blob key when using the traditional
attach method. However, I cannot figure out how to specify the key when using direct uploads. The direct upload method was also updated in this PR, so I’m hoping I’m missing something.
As far as I can tell, if I want to send in a custom key such as
user.company/public/filename using direct uploads I…can’t? I’d have to hook in here: rails/activestorage.js at b5dac96b59a582c7968b0c33d6ff39d1cfc336dc · rails/rails · GitHub
var blob = new BlobRecord(_this.file, checksum, _this.url);
Even if I send in a
this.key to my direct uploads controller, I don’t want to change the call to BlobRecord and I don’t want to patch activestorage.js b/c that will certainly cause trouble in the future.
I can override
blob.rb, but I want to prefix based on user.company, so I need to send in the user details somehow.
Can I send a
key variable with this new PR via direct uploads? I know this was previously not how ASt was designed, but the above PR makes me hopeful there may be a way.