-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
First pass on documentation for using Shrine for attachments #154
First pass on documentation for using Shrine for attachments #154
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<%= render Syntax.new("js") do %> | ||
this.addEventListener(`rhino-attachment-add`, async function(event) { | ||
event.preventDefault() | ||
const { attachment, target } = event; | ||
|
||
const url = event.target.dataset.directUploadUrl | ||
|
||
let formData = new FormData() | ||
formData.append('file', attachment.file, attachment.file.name) | ||
|
||
let response = await window.mrujs.fetch(url, { | ||
method: 'POST', | ||
body: formData, | ||
headers: {"Accept": "application/json"} | ||
}); | ||
|
||
let result = await response.json(); | ||
|
||
attachment.setAttributes({ | ||
url: result.url, | ||
}); | ||
|
||
attachment.setUploadProgress(100) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. This is surprisingly easy...
I have many questions:
If you're using Shrine, do you lose out on the ability to find attachments when querying ActionText? Or is it an implementation detail and it still works because it thinks everything is ActiveStorage?
This is fantastic work!! Thank you so much!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure! I only use the JSON serialized versions, so I’m not sure about ActionText 😅
and thank you!!
No description provided.