-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Firebase Upload URL issue #27
Comments
Hi @AlexHyslop I think you'll need to supply a firebase function where you'll handle the If you can share more information about what this Hope that help. |
could you please make a function to handle |
To upload files with I'm doing something like this to allow trix attachment uploads to Firebase cloud storage on my app, Fileinbox, using Firebase v9: import { useEffect, useState } from "react";
import { getStorage, ref, uploadBytes, deleteObject } from "firebase/storage";
function TrixComponent({ value, onChange }) {
const [editor, setEditor] = useState(null);
const storage = getStorage();
const events = {
"trix-attachment-add": async (e) => {
const file = e.attachment.file;
if (file) {
const storageRef = ref(storage, file.name);
const snap = await uploadBytes(storageRef, file);
const url = await getDownloadURL(snap.ref);
e.attachment.setAttributes({ url, href: url });
}
},
"trix-attachment-remove": (e) => {
const storageRef = ref(storage, e.attachment.attachment.attributes.values.path);
remove(storageRef);
},
"trix-file-accept": (e) => {
if (!e.file.type.includes("image/")) {
alert("Only image attachments are allowed for now.");
e.preventDefault();
}
},
};
// add event listeners to the Trix object instead of on window to support multiple Trix editors per page
useEffect(() => {
if (editor)
Object.entries(events).forEach(([name, fn]) =>
editor.element.addEventListener(name, fn)
);
return () =>
Object.entries(events).forEach(([name, fn]) =>
editor?.element.removeEventListener(name, fn)
);
}, [editor]);
return (
<TrixEditor
onEditorReady={setEditor}
value={value}
onChange={(html, text) => onChange(html)}
/>
);
} |
I am trying to use this with Firebase but am having issues getting the uploadURL to work.
The images are not getting uploaded to Firebase
my form :
The text was updated successfully, but these errors were encountered: