1 | <?php |
||
28 | class ContentUploader extends Uploader implements ContentUploaderInterface |
||
29 | { |
||
30 | /** |
||
31 | * Default MIME type |
||
32 | */ |
||
33 | const DEFAULT_MIME_TYPE = 'application/octet-stream'; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $filePrefix = 'magento_api'; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * @var \LizardMedia\ProductAttachment\Api\Data\AttachmentInterface |
||
44 | */ |
||
45 | private $attachmentConfig; |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @var \Magento\Framework\Filesystem\Directory\WriteInterface |
||
50 | */ |
||
51 | protected $mediaDirectory; |
||
52 | |||
53 | |||
54 | /** |
||
55 | * @var \Magento\Framework\Filesystem\Directory\WriteInterface |
||
56 | */ |
||
57 | protected $systemTmpDirectory; |
||
58 | |||
59 | |||
60 | /** |
||
61 | * @param \LizardMedia\ProductAttachment\Api\Data\AttachmentInterface $attachment |
||
62 | * @param \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb |
||
63 | * @param \Magento\MediaStorage\Helper\File\Storage $fileStorage |
||
64 | * @param \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension $validator |
||
65 | * @param \Magento\Framework\Filesystem $filesystem |
||
66 | * |
||
67 | * @throws \Magento\Framework\Exception\FileSystemException |
||
68 | */ |
||
69 | public function __construct( |
||
83 | |||
84 | |||
85 | |||
86 | /** |
||
87 | * @param \Magento\Downloadable\Api\Data\File\ContentInterface $fileContent |
||
88 | * @param string $contentType |
||
89 | * |
||
90 | * @throws \InvalidArgumentException |
||
91 | * @throws \Exception |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | public function upload(ContentInterface $fileContent, string $contentType) : array |
||
113 | |||
114 | |||
115 | /** |
||
116 | * Decode base64 encoded content and save it in system tmp folder |
||
117 | * |
||
118 | * @param ContentInterface $fileContent |
||
119 | * |
||
120 | * @throws \Magento\Framework\Exception\FileSystemException |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | protected function decodeContent(ContentInterface $fileContent) |
||
137 | |||
138 | /** |
||
139 | * @return string |
||
140 | */ |
||
141 | protected function getTmpFileName() |
||
145 | |||
146 | |||
147 | /** |
||
148 | * @param string $contentType |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | protected function getDestinationDirectory($contentType) |
||
156 | } |
||
157 |