Comments (12)
for me, this works fine :) here a very simple example:
$id = Uuid::randomHex();
$mediaRepo = RepositoryFactory::create(MediaDefinition::ENTITY_NAME);
$mediaRepo->create([
'id' => $id,
// 'mediaFolderId' => '<id>'
], $context);
$adminService = new AdminActionService($context);
$adminService->execute('post', "/api/_action/media/{$id}/upload?extension=jpg", [
'url' => $url,
]);
$adminService->execute('post', "/api/_action/media/{$id}/rename", [
'fileName' => 'My Name '.time(),
]);
see the documention https://shopware.stoplight.io/docs/admin-api/ZG9jOjEyNjI1Mzkw-media-handling
from shopware-php-sdk.
Is there an ETA for this?
from shopware-php-sdk.
Hey, currently no, I need some input for the requirements. Can you give me an idea of how you need this feature to be done? Then I can have a better idea of the feature
from shopware-php-sdk.
Currently it isnt possible to handle Medias?
from shopware-php-sdk.
o handle
@t-poeschl I mean you can still work with Media as other entities, just other specific apis for media is not available like upload file, etc. However, you can still use AdminActionService for generic admin apis if you know the endpoint
from shopware-php-sdk.
I updated it in the lastest version, feel free to reopen ticket if you have any issue
And also I added a new MediaService, now you can use the MediaService instead
#44
from shopware-php-sdk.
@okuehne The link to the docs doesn't exist anymore and the context of this issue is gone. What was the reason to do a renaming of an newly uploaded file?
from shopware-php-sdk.
@flagbird The API still exists (but somehow the docs are weirdly gone) so the use case could vary depending on the consumer
from shopware-php-sdk.
@vienthuong Thanks for the answer. I don't see the need of doing a rename after an upload without a given context why. Someone copied and pasted this solution only with the link to this issue and I can't reverse-engineer the reason why it was done this way.
from shopware-php-sdk.
@flagbird it's a long time ago but I think for the convenient shake, I just ported all the media service endpoints to the SDK (I did it from time to time since Shopware API keeps updating), the rename API itself is mostly used for internal purposes where you can rename your uploaded file from the UI for whatever reason. But it won't hurt either way, you don't need to rename the uploaded file after uploading it. Or if you face an issue related to this API, feel free to ask here or open a discussion :)
from shopware-php-sdk.
Hi @vienthuong, I think I left a wrong impression here. This is no issue with the lib itself. It's fine as it is, even in the older version. But someone in a project had to write code in a hurry that's based on @okuehne example and I tried to find out if rename
right after upload
was used for a reason, that was elaborated in the outdated docs link or if it was just copy-paste code to save time. I can't tell by reading the history of this issue. I've settled to drop the rename
, update the upload
logic for using a filename and see what will happen. Thanks again.
from shopware-php-sdk.
No worry @flagbird, I got your concern :) your assumption is correct, his example is just purely to showcase what you can possibly do with the media endpoints. If you have trouble with using the upload endpoint please feel free to raise it as well
from shopware-php-sdk.
Related Issues (20)
- Cant get Transaction and Delivery Status HOT 1
- Don't cache entities HOT 5
- EntityRepository::searchIds does not throw ShopwareSearchResponseException HOT 3
- Does this sdk work with custom entities? HOT 3
- PHP 8.1 compatibility HOT 6
- EntityCollection is returned for empty results HOT 2
- Self signed certificate HOT 1
- GET Requests are not validated correctly HOT 2
- Call to a member function getSource() on null HOT 7
- Connecting properties, categories and tags to product (question) HOT 2
- Dieser Wert sollte nicht leer sein. c1051bb4-d103-4f74-8988-acbcafc7fdc3 HOT 2
- Transaction commit failed because the transaction has been marked for rollback only HOT 5
- Create Order Delivery HOT 2
- SDK version mismatch HOT 1
- Document download not possible
- The resource owner or authorization server denied the request. Access token could not be verified. HOT 7
- Add support for criteria in SyncService / SyncPayload
- Allowed memory size exhausted HOT 3
- OrderReturnLineItemEntity is missing (part of Shopware Commercial plugin)
- dynamic properties and package versioning HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopware-php-sdk.