Skip to content
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

Merged

Conversation

tcannonfodder
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Feb 2, 2024

⚠️ No Changeset found

Latest commit: 7211ffd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
rhino-editor ✅ Ready (Inspect) Visit Preview Feb 2, 2024 9:20pm

Comment on lines +19 to +42
<%= 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)
})
Copy link
Owner

@KonnorRogers KonnorRogers Feb 3, 2024

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!!

Copy link
Contributor Author

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!!

@KonnorRogers KonnorRogers merged commit 1bfd52b into KonnorRogers:main Feb 27, 2024
7 checks passed
@KonnorRogers KonnorRogers mentioned this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants