FabricJS Android App Save Blob Problem - Forum

Forum Navigation
You need to log in to create posts and topics.

FabricJS Android App Save Blob Problem

Hi guys,

I'm using FabricJS to make a very simple app.
I Use Website2APK builder to make APK and it solve problem with CORS origins.
(Has an option to allow it)

But when I want save final file to jpg or png I get an error in Android and it says only can save http or https content and FabricJS gives blob format. (SaveFile command in Fabric)

I know that there is a command fabSaveAsBase64 and then Base64ToLocalFile I never tested that, because I don't know what format will be generated file... jpg? png? svg?
and if it is JPG can I change quality like fabSaveAsJPG?

EDIT: I have tested that method above and I get same error (blob format)

Is there any way to fix that?
So I can make Android apps with Fabric

Thanks :)

@noyzen I don't understand why are you having such a problem. Have you checked the included sample app in this location?:
My Documents\VisualNeoWeb\Sample Apps\FabricCanvas

Regards.

noyzen has reacted to this post.
noyzen

Yes, I have checked Sample apps and It works on server.

But as offline app in android FabricJS can not save file, I get an error which says URI must be http or https but Its blob.

@noyzen, not sure but you can try to convert the blob URI to a data URI. A data URI allows you to embed data directly into the URL, which can be used for images, files, or other types of data. To convert a Blob to a data URI, you can use the FileReader API. Here's an example:

BeginJS
  reader = new FileReader();
  reader.onload = function(event) {
    $App.dataURI = event.target.result; // Use [dataURI] in neoScript
  };
  reader.readAsDataURL($App.blob); // [blob] refers to your Blob object
EndJS

 

noyzen has reacted to this post.
noyzen

Thank you Luis,

This command: fabSaveAsJPG gives the blob URI. how can I use your JS code with command?

I think you can try to edit FabricJS plugin, I need to export canvas for JPG (with quality setting) and PNG like what Fabric doing now in desktop server.

FabricJS is amazing plugin!