I am trying to get the file from a 3-d party server using \Magento\Framework\HTTP\Adapter\Curl in my model. My aim is to record this file in the file on my server inside magento. The thing is the request passes successfully, I am getting the reply, but the file is created blank (zero byte file) and nothing is recorded in it. Here is the example of my code:
/** * @var \Magento\Framework\Filesystem\Directory\Write * @var \Magento\Framework\HTTP\Adapter\Curl * @var string $destination * @var string $source */ $newFile = $this->_directory->getDriver()->fileOpen($destination, "wb"); $this->_curl->addOption(CURLOPT_FILE, $newFile); $this->_curl->write(\Zend_Http_Client::GET, $source); $result = $this->_curl->read();
As a result i have the full reply in
$result , the blank file in
$destination .There are enough permissions i.e. even setting 777 on the directory and a current file, the result is not changing.
drwxrwxrwx 3 501 www-data 102 Apr 5 08:56 . drwxrwxrwx 3 501 www-data 102 Apr 5 08:10 .. -rw-rw-rw- 1 501 www-data 0 Apr 5 08:59 file_temp.gz