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