You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with the flutter_quill_extentions to allow users to insert images into the QuillEditor. I am running into issues when using web. A user is able to select an image from the machine and it will appear fine inside of the QuillEditor, but the URL is a blob. I am attempting to intercept the file, upload it to our server and then replace the url with our hosted one. So that the image can be viewable by others. Below is an example of my code. The problem that I am facing is that I have no information about the file that was selected, such as name or mine type. Does anyone have any ideas how to get this information?
final quillHTMLToolbar = QuillToolbar.simple(
configurations: QuillSimpleToolbarConfigurations(),
embedButtons: FlutterQuillEmbeds.toolbarButtons(
videoButtonOptions: null,
imageButtonOptions: QuillToolbarImageButtonOptions(
imageButtonConfigurations: QuillToolbarImageConfigurations(
onImageInsertedCallback: (imageUrl) async {
// Check if the imageUrl is a blob URL
if (imageUrl.startsWith('blob:')) {
// Handle the blob URL by uploading the image to the server
final uploadedImageUrl = await model.uploadBlobImageToServerWeb(imageUrl);
// Replace the blob URL with the uploaded image URL in the editor
final controller = model.quillPrefilledController;
final index = controller.selection.baseOffset;
// Remove the blob URL and replace it with the server URL
controller.replaceText(
index,
1,
BlockEmbed.image(uploadedImageUrl),
null,
);
}
},
),
),
),
controller: model.quillPrefilledController,
),
);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am working with the flutter_quill_extentions to allow users to insert images into the QuillEditor. I am running into issues when using web. A user is able to select an image from the machine and it will appear fine inside of the QuillEditor, but the URL is a blob. I am attempting to intercept the file, upload it to our server and then replace the url with our hosted one. So that the image can be viewable by others. Below is an example of my code. The problem that I am facing is that I have no information about the file that was selected, such as name or mine type. Does anyone have any ideas how to get this information?
Beta Was this translation helpful? Give feedback.
All reactions