Skip to content
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

Media upload using API #290

Closed
nvdid opened this issue Feb 1, 2024 · 5 comments
Closed

Media upload using API #290

nvdid opened this issue Feb 1, 2024 · 5 comments

Comments

@nvdid
Copy link

nvdid commented Feb 1, 2024

Is your feature request related to a problem?
Couldn't find in documentations a straight forward way of uploading images and linking them to products / categories

Describe the solution you'd like
An API for uploading images that can save the media for a product / category etc.

Describe alternatives you've considered
Uploading the media using file system, then linking it using current APIs somehow. But how? Is there documentations for it?

Additional context

@nvdid
Copy link
Author

nvdid commented Feb 1, 2024

Also it's related to previews and stuff which should be auto generated

@aimeos
Copy link
Owner

aimeos commented Feb 1, 2024

File uploads are currently missing in the GraphQL API and haven't been available in the JsonAdm API at all. If you can provide a pull request for the GraphQL API, we are happy to integrate it into the core

@nvdid
Copy link
Author

nvdid commented Feb 1, 2024

Would be happy to, though having a quick look on the project🤕 tells me I'm not currently capable of.

I try cURLing on current APIs if possible. I tried to remake a request to http://localhost/admin/default/jqadm/save/product using create product but I get 419:Expired error.

@nvdid
Copy link
Author

nvdid commented Feb 1, 2024

So far I managed to add a product the high way. I hope it works for now and hope we'll have the API soon.

set host=http://localhost

set rem-key=remember_web_....
set rem-value=...
set xsrf-token=...
set session=...
set _token=...

set sku=...
set label=...
set ctime=2024-02-01 18:30

set media-file=...
set media-label=...

set desc-short=...
set desc-long=...

set price-value=299
set price-tax=4.0
set price-rebate=10.0
set price-ship=5
set price-currency=USD

set category=...

curl -X POST -H "Connection: keep-alive" -H "Content-Type: multipart/form-data" ^
-H "Cookie: %rem-key%=%rem-value%; XSRF-TOKEN=%xsrf-token%; aimeos_session=%session%" ^
-H "Upgrade-Insecure-Requests: 1" ^
-F "next=get" ^
-F "_token=%_token%" ^
-F "item[product.status]=1" ^
-F "item[product.type]=default" ^
-F "item[product.code]=%sku%" ^
-F "item[product.label]=%label%" ^
-F "item[product.scale]=1" ^
-F "item[product.ctime]=%ctime%" ^
-F "item[product.boost]=1" ^
-F "item[config][0][key]=css-class" ^
-F "media[0][media.status]=1" ^
-F "media[0][media.type]=default" ^
-F "media[0][media.label]=%media-label%" ^
-F "media[0][product.lists.type]=default" ^
-F "text[0][text.content]=%desc-short%" ^
-F "text[0][text.status]=1" ^
-F "text[0][text.type]=short" ^
-F "text[0][product.lists.type]=default" ^
-F "text[1][text.content]=%desc-long%" ^
-F "text[1][text.status]=1" ^
-F "text[1][text.type]=long" ^
-F "text[1][product.lists.type]=default" ^
-F "price[0][price.taxrates][]=%price-tax%" ^
-F "price[0][price.value]=%price-value%" ^
-F "price[0][price.rebate]=%price-rebate%" ^
-F "price[0][price.costs]=%price-ship%" ^
-F "price[0][price.status]=1" ^
-F "price[0][price.currencyid]=%price-currency%" ^
-F "price[0][price.type]=default" ^
-F "price[0][price.quantity]=1" ^
-F "price[0][product.lists.type]=default" ^
-F "stock[0][stock.stockflag]=1" ^
-F "stock[0][stock.type]=default" ^
-F "category[default-0][product.lists.type]=default" ^
-F "category[default-0][product.lists.refid]=%category%" ^
-F "download[product.lists.siteid]=1." ^
-F "download[attribute.status]=1" ^
-F "media[0][file]=@%media-file%" ^
-F "item[product.id]=" ^
-F "item[product.url]=" ^
-F "item[product.datestart]=" ^
-F "item[product.dateend]=" ^
-F "item[product.target]=" ^
-F "item[config][0][val]=" ^
-F "media[0][media.id]=" ^
-F "media[0][media.url]=" ^
-F "media[0][media.languageid]=" ^
-F "media[0][product.lists.datestart]=" ^
-F "media[0][product.lists.dateend]=" ^
-F "text[0][text.id]=" ^
-F "text[0][text.languageid]=" ^
-F "text[0][text.label]=" ^
-F "text[0][product.lists.datestart]=" ^
-F "text[0][product.lists.dateend]=" ^
-F "text[1][text.id]=" ^
-F "text[1][text.languageid]=" ^
-F "text[1][text.label]=" ^
-F "text[1][product.lists.datestart]=" ^
-F "text[1][product.lists.dateend]=" ^
-F "price[0][price.id]=" ^
-F "price[0][product.lists.datestart]=" ^
-F "price[0][product.lists.dateend]=" ^
-F "stock[0][stock.stockdiff]=" ^
-F "stock[0][stock.dateback]=" ^
-F "stock[0][stock.timeframe]=" ^
-F "stock[0][stock.id]=" ^
-F "physical[package-length]=" ^
-F "physical[package-width]=" ^
-F "physical[package-height]=" ^
-F "physical[package-weight]=" ^
-F "category[default-0][product.lists.id]=" ^
-F "download[product.lists.id]=" ^
-F "download[attribute.id]=" ^
-F "download[attribute.label]=" ^
-F "download[file]=; filename=; headers=\"Content-Type=application/octet-stream\"" ^
"%host%/admin/default/jqadm/save/product?locale=en"

@aimeos
Copy link
Owner

aimeos commented Oct 31, 2024

The GraphQL file upload API is now available: https://aimeos.org/docs/latest/admin/graphql/media/#save-media-with-file-upload

@aimeos aimeos closed this as completed Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants