-
-
Notifications
You must be signed in to change notification settings - Fork 873
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
[3.3] File uploading doesn't work anymore #6342
Comments
I think this is fixed by adding this to the config file: #6343 (comment) You might then run into a problem with permitted Content-Types, depending on what you have in your global configuration for input types. You can add multipart to the input format for the affected endpoints using the second option from this comment, if you need it. #6275 (comment) |
#6343 (comment) this should be it sorry for the trouble let me know if setting |
Hello, first of all, thank you for the hints. I set I also added the argument The missing part is the assertions: I configured two entities, one for docs and one for images. Each one has its own allowed mime types. For example, this is the entity to upload a doc (simplified for the purposes of the comment): #[ORM\Entity]
#[Vich\Uploadable]
#[API\ApiResource(
normalizationContext: ['groups' => [FileDocVich::GROUP_NOR_READ]],
types: [self::API_TYPE],
operations: [
new API\Get(
...
),
new API\Post(
inputFormats: ['multipart/form-data' => ['multipart/form-data']],
...
),
],
)]
class FileDocVich extends FileAbstractVich
{
...
private const array MIME_TYPES_ALLOWED = ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
...
#[Vich\UploadableField(mapping: 'file_doc', fileNameProperty: 'name', size: 'size', mimeType: 'mimeType', originalName: 'originalName')]
#[Assert\NotNull(groups: [self::GROUP_VAL_POST])]
#[Assert\File(maxSize: '5M', mimeTypes: self::MIME_TYPES_ALLOWED)]
protected ?File $file = null; The Any idea why the assertions are not working anymore? |
can you run the |
@soyuka , how is the command supposed to work? I've tried three alternatives: bin/console debug:api-resource FileDocVich
bin/console debug:api-resource \Coommercio\App\Common\Entity\FileDocVich
bin/console debug:api-resource Coommercio\\App\\Common\\Entity\\FileDocVich No one of these works. In the code, I see the backslashes are removed from the class: When calling a route, instead, the namespace is correct. Which is the correct way of using the command? |
|
|
I tried |
API Platform version(s) affected: 3.3.0
Description
The upload of files, as described in the official docs, doesn't work anymore.
How to reproduce
Follow the instructions here: https://api-platform.com/docs/core/file-upload/
Possible Solution
OR
Additional Context
The error is this:
The text was updated successfully, but these errors were encountered: