2

I have a REST api, and I'm submitting GIF files to it basically. It's returning a 400 error though.

This is the code that handles the conversion at the minute.

        $imgstr = $params['file'];

        $dataObject = str_replace("data:image/gif;base64,", "", $imgstr);

        $file = base64_decode($dataObject);

        $entity->setDescription($params['description']);
        $entity->setFile($dataObject);
        $entity->setUser($user);

        $em->persist($entity);
        $em->flush();

The setFile() method expects a Symfony\Component\HttpFoundation\File\UploadedFile object. It works with normal form submissions from the web front-end, just not the app.

It does pick up the binary string with the mime type prepended etc. But it won't store it.

Cheers

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.