How to deal with "Resource id #XXX" (LongBlob) in Angular?

It’s been many days from now that I’m trying to display a Blob (image storred in my database) in my Angular project (Angular 10.0.7).

I have a REST API in Symfony 4.3.11 and it works well.

The Blob in my database (MySQL) is encoded in Base64, the type is, to be precised, LONGBLOB. I tried to decode it using online WebSite and that’s working, I have my image back.

That problem is that when I run my request, I get :

"image": "Resource id #788",

My Entity in Symfony is :

    /**
     * @var string|null
     *
     * @ORMColumn(name="IMAGE", type="blob", length=0, nullable=true)
     */
    private $image;

I have tried to replace the type with "text" or "string" but I get this error :

{
    "code": 500,
    "message": "Your data could not be encoded because it contains invalid UTF8 characters."
}

On the Angular side I have this when I try to print the image in my Browser :

<img _ngcontent-shg-c116="" src="unsafe:data:image/png;base64,Resource id #788">

That’s seem legit because my request returned this string…

How to deal with this on my Angular ? Or do I have to change my request ? And if so, how ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *