question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello, I would like to store documents in a blob field. For that I have the following entity:

/**
 * @ApiResource(
 *     collectionOperations={
 *       "get"={"method"="GET", "normalization_context"={"groups"={ "get_document"}}},
 *       "post"={"method"="POST", "denormalization_context"={"groups"={"post_document"}}},
 *     },
 *     itemOperations={
 *       "get"={"method"="GET", "normalization_context"={"groups"={"get_document"}}},
 *       "put"={"method"="PUT", "denormalization_context"={"groups"={"put_document"}}},
 *       "delete"={"method"="DELETE"},
 *     },
 *     attributes={"order"={"dateDocument": "ASC"}}
 * )
 * @ApiFilter(SearchFilter::class, properties={"logement.id": "exact"})
 * @ORM\Entity(repositoryClass="App\Repository\DocumentRepository")
 */
class Document
{
    /**
     * @ORM\Id()
     * @Groups({"get_document"})
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer", name="id_document")
     */
    private $id;

    /**
     * @Groups({"get_document"})
     * @ORM\Column(type="blob")
     */
    private $contenuDocument;

...

When I do a get_document, I get the following message:

title :  An error occurred
detail: An unexpected value could not be normalized: NULL

Do you have an idea please?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
teohhanhuicommented, Jun 19, 2019

Anyway, I’m not sure embedding binary data in JSON makes sense…

1reaction
jguyenotcommented, Jun 19, 2019

Thanks for your quikly answer.

I think i will create a custom controller to return the filestream directly. I think it’s a best practice that retourn this stream in base64 (front js is not the best for decoding)

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upload a blob using .NET - Azure Storage - Microsoft Learn
Upload to a stream in Blob Storage ... You can open a stream in Blob Storage and write to that stream. The following...
Read more >
How can javascript upload a blob? - jquery - Stack Overflow
append call, trying to get the blob data as a string by getting the values at URL.
Read more >
How to Upload a File to Azure Blob Storage
Now that we uploaded the data to the Azure storage account let's open the Azure portal to verify the upload. Open the container's...
Read more >
How to Upload a File to Azure Blob Storage | .NET 6 - YouTube
Azure Blob Storage offers a simple way to store files such as images or JSON data in the cloud. This tutorial will teach...
Read more >
How can JavaScript upload a blob ? - GeeksforGeeks
There are many ways to upload a blob (a group of bytes that holds the data stored in a file) in JavaScript, using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found