[DEV-367] Use FileDownloader instead of fopen
This commit is contained in:
parent
68b2d2bf63
commit
40016635a8
|
@ -52,10 +52,13 @@ class CSVImportController extends Controller {
|
|||
throw new RequestException(ERRORS::INVALID_FILE);
|
||||
}
|
||||
|
||||
$file = fopen($fileUploader->getFullFilePath(),'r');
|
||||
$fileDownloader = FileDownloader::getInstance();
|
||||
$fileDownloader->setFileName($fileUploader->getFileName());
|
||||
$file = $fileDownloader->fopen();
|
||||
|
||||
$errors = [];
|
||||
|
||||
while(($user = fgetcsv($file)) != false) {
|
||||
while($file && ($user = fgetcsv($file)) != false) {
|
||||
Controller::setDataRequester(function ($key) use ($user) {
|
||||
switch ($key) {
|
||||
case 'email':
|
||||
|
|
|
@ -23,6 +23,16 @@ class FileDownloader extends FileManager {
|
|||
}
|
||||
}
|
||||
|
||||
public function fopen() {
|
||||
$fullFilePath = $this->getFullFilePath();
|
||||
|
||||
if(file_exists($fullFilePath) && is_file($fullFilePath)) {
|
||||
return fopen($fullFilePath, 'r');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function eraseFile() {
|
||||
unlink($this->getLocalPath() . $this->getFileName());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue