lizardmedia / product-attachments-magento2

Magento2 module for adding downloadable product attachments
MIT License
40 stars 37 forks source link

External script #52

Open bylli79 opened 3 years ago

bylli79 commented 3 years ago

Hello, how can i use this module from an external script in php?

Thank you

bylli79 commented 3 years ago

if I use this code $sampleContent = $objectManager->create(\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class)->create(); $sampleContent->setFileData( @codingStandardsIgnoreLine base64_encode(file_get_contents( '/var/www/html/jellyfish_1_3.pdf')) ); $sampleContent->setName('jellyfish_1_3.pdf'); $sampleContent->setType('application/octet-stream');

$upload =$objectManager->create(LizardMedia\ProductAttachment\Api\Data\File\ContentUploaderInterface::class); $upload->upload($sampleContent,"file");

I get the following error: PHP Fatal error: Uncaught Magento\Framework\Exception\RuntimeException: Type Error occurred when creating object: Magento\MediaGalleryIntegration\Plugin\SaveImageInformation, Argument 6 passed to Magento\MediaGalleryIntegration\Plugin\SaveImageInformation::__construct() must be of the type array, null given, called in /vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 in /vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131

What can I do?