can anyone give an example on how to upload image file via the api when creating a product.?
the documentation doesn't show it. I am using guzzle. any help please?
no matter what file I send it, it keeps saying this
"Expected argument of type "SplFileInfo or null", "array" given"
Someone can help?
left sylius to woo api. never got an answer anywhere.
Hello,
I just looked at the doc, it seem to be explain : http://docs.sylius.org/en/latest/api/products.html
Note
The images (files) should be passed in an array as an attribute of request. See how it is done in Sylius here. https://github.com/Sylius/Sylius/blob/master/tests/Controller/ProductApiTest.php
Ok @bruno-ds , I understand how to push image to sylius with API with they're examples https://github.com/Sylius/Sylius/blob/master/tests/Controller/ProductApiTest.php#L483
But I do not understand how to push image without using UploadedFile which is a symfony component... so there is a way to push image with tranditionnal php libs ? or equivalent ?
Probably, it's role is just to serialize the file, you should look at the raw request sent (there should be a method like $this->client->getRequest()).
But since Sylius rely on Symfony, using UploadedFile seems the easiest way...
Am I correct to assume that currently it's not possible to upload images into Sylius purely using its REST API, without creating any Symfony plugins?
My usecase is that I'm trying to upload images into Sylius from my GO app, and I don't want to create any plugins for it.
Does it still not possible in 2020? It's really hard to upload photos via API in some cases impossible
@kaankilic There's an workaround: https://github.com/Sylius/Sylius/issues/10532
Hi @bruno-ds
I am sending the images in the same format in the request data in sylius API as given in the file https://github.com/Sylius/Sylius/blob/master/tests/Controller/ProductApiTest.php#L483
but the image is not creating at sylius.
Can anyone help me?
Actually I am sending as below:
[
"code" => "test1"
"productTaxons" => ""
"channels" => array:1 [
0 => "FASHION_WEB"
]
"images" => array:1 [
0 => array:2 [
"file" => Symfony\Component\HttpFoundation\File\UploadedFile {#4178
-test: false
-originalName: "ee275acf9e7bcd61c705744c071b70537016a470_fd70e285b38e2a5a60cb486805fb7e8f933c6e00_trophix_36"
-mimeType: "application/octet-stream"
-size: null
-error: 0
path: "/home/users/krishna.kant/www/html/pim-community-standard/app/file_storage/catalog/e/e/2/7"
filename: "ee275acf9e7bcd61c705744c071b70537016a470_fd70e285b38e2a5a60cb486805fb7e8f933c6e00_trophix_36.png"
basename: "ee275acf9e7bcd61c705744c071b70537016a470_fd70e285b38e2a5a60cb486805fb7e8f933c6e00_trophix_36.png"
pathname: "/home/users/krishna.kant/www/html/pim-community-standard/app/file_storage/catalog/e/e/2/7/ee275acf9e7bcd61c705744c071b70537016a470_fd70e285b38e2a5a60cb486805fb7e8f933c6e00_trophix_36.png"
extension: "png"
realPath: "./app/file_storage/catalog/e/e/2/7/ee275acf9e7bcd61c705744c071b70537016a470_fd70e285b38e2a5a60cb486805fb7e8f933c6e00_trophix_36.png"
aTime: 2020-06-01 18:20:54
mTime: 2020-06-01 18:18:55
cTime: 2020-06-01 18:18:55
inode: 19529734
size: 314470
perms: 0100644
owner: 1282
group: 500
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
"type" => "Main"
]
]
"associations" => array:1 [
"similar_products" => ""
]
"enabled" => false
"translations" => array:1 [
"en_US" => array:3 [
"name" => "dffddddff"
"slug" => "test1"
"description" => "
JHDJHJ
"
Most helpful comment
Hello,
I just looked at the doc, it seem to be explain : http://docs.sylius.org/en/latest/api/products.html