Import to file manager from URL

Permalink
I am making a package for the marketplace, and I'd like to import images from a URL to the file manager.

Is this possible without saving the file to the file system?
(In other words, without using file_put_contents)

 
wardhache replied on at Permalink Best Answer Reply
For future reference :

Importing a file from a url in Concrete5 can be done with the file helper class.

use \Concrete\Core\File\Importer;
use \Concrete\Core\File\Service\File as FileHelper;


$fileContent = FileHelper::getContents($fileUrl);
if ($fileContent != false) {
    FileHelper::append(FileHelper::getTemporaryDirectory() . '/' . $fileName, $fileContent);
    $importer = new Importer();
    $result = $importer->import(FileHelper::getTemporaryDirectory() . '/' . $fileName, $fileName);
    FileHelper::clear(FileHelper::getTemporaryDirectory() . '/' . $fileName);
}
somesayinice replied on at Permalink Reply
Thank you so much. You have no idea how much this "little" note helped me. Much much appreciated.
omars786 replied on at Permalink Reply
omars786
Thank you for updating this thread