Giter VIP home page Giter VIP logo

Comments (12)

okuehne avatar okuehne commented on August 18, 2024 1

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.

qx54 avatar qx54 commented on August 18, 2024

Is there an ETA for this?

from shopware-php-sdk.

vienthuong avatar vienthuong commented on August 18, 2024

@qx54

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.

t-poeschl avatar t-poeschl commented on August 18, 2024

Currently it isnt possible to handle Medias?

from shopware-php-sdk.

vienthuong avatar vienthuong commented on August 18, 2024

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.

vienthuong avatar vienthuong commented on August 18, 2024

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.

flagbird avatar flagbird commented on August 18, 2024

@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.

vienthuong avatar vienthuong commented on August 18, 2024

@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.

flagbird avatar flagbird commented on August 18, 2024

@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.

vienthuong avatar vienthuong commented on August 18, 2024

@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.

flagbird avatar flagbird commented on August 18, 2024

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.

vienthuong avatar vienthuong commented on August 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.