-
-
Notifications
You must be signed in to change notification settings - Fork 489
Detect extension if no one is provided #2285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect extension if no one is provided #2285
Conversation
I faced the same problemas @sarim. Does this PR fixes your problem also? |
This is my code to upload media:
This is my hack around this issue:
It was working on previous SonataMediaBundle versions, and it works with this fix. |
Yeah my code was also working on previous versions, then I upgraded the project and had to apply to following workaround make it work in current sonata media. I won't go into details now, I think I tried my best to explain it in previous two threads, kinda felt like I was not being heard. Here in this workaround saving the file under its original name makes it have an extension. $upload = $request->files->get('files')[0];
+ $file = $upload->move(\sys_get_temp_dir(), \uniqid().$upload->getClientOriginalName());
+
$media = new Media();
- $media->setBinaryContent($upload->getPathname());
- $media->setName($upload->getClientOriginalName());
- $mediaManager->save($media, $context, 'sonata.media.provider.image');
+ $media->setBinaryContent($file->getPathname());
+ $media->setName($file->getFilename());
+ $media->setContext($context);
+ $media->setProviderName('sonata.media.provider.image');
+ $mediaManager->save($media); |
I will need to do a manual release for this one (and a merge to 4.x also) @VincentLanglet, but I would like it to land on 3.x first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a test possible ?
Yes! done |
@jordisala1991 The 3.x branch is not available anymore on https://master-7rqtwti-ptm4dx6rjpjko.eu-5.platformsh.site/next-releases so the changelog need to be written manually. Will try to find time tomorrow |
No worries, I am on it right now |
Subject
I am targeting this branch, because this is BC.
Closes #2208 .
Changelog