What I did was hardcoding the path of where to save the local file from S3 and then return the path. So far it works, will need further testing to see if it has other problem. Haven't have enough time to look into making it fully dynamic.
What I did was, create another abstract class to use ImportModel and then specify a new class to use as import_file.
And inside that new class, I overwrite the function getLocalPath() to,
public function getLocalPath()
{
if ($this->isLocalStorage()) {
return $this->getLocalRootPath() . '/' . $this->getDiskPath();
}
else {
//
// @todo The CDN portion of this method is not complete.
// Things to consider:
// - Generating the temp [cache] file only once
// - Cleaning up the temporary file somehow
// - See media manager process as a reference
//
$storagePath = 'uploads/public/'.$this->getPartitionDirectory(). $this->disk_name;
$localPath = $this->getLocalTempFilePath($this->file_name);
//FileFacade is actually Illuminate\Support\Facades\File
FileFacade::put($localPath, Storage::get($storagePath));
return $localPath;
}
}
protected function getLocalTempFilePath($fileName)
{
$fileName = md5($fileName.uniqid().microtime());
$path = temp_path() . '/uploads';
if (!FileFacade::isDirectory($path))
FileFacade::makeDirectory($path, 0777, true, true);
return $path.'/'.$fileName;
}
We need some solution to flag the file upload as local, since it doesn't need to be stored on a CDN. Can someone log an issue for this on the octobercms/october GitHub repo and we'll take a look at it.