0

When not working with products, is there a magento2 model/function that can be used for reading/writing images to the media folder? (like addImageToMediaGallery / getMediaGalleryProcessor()->addImage used when working with products).

I've made a module that loads data from an api/json link into to a custom table where one column is an image URL. I wan't to save the image from the link to the local media folder.

I know I can do this with PHP (file_put_contents, fwrite, curl), but I'm thinking there must be a "Magento way" to do this?

I get the image url by $image = $this->myRepository->getImageUrl($data['image_url']);

asked Aug 21, 2018 at 9:29

1 Answer 1

0

Solved it.

I just used Magento\Framework\Filesystem\Io\File; and $this->file->read($originalImageUrl, $newImage);

answered Aug 22, 2018 at 7:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.