protected function setUp() { $this->file_name = "unit_test.txt"; $file_path = GetFilePathInWorkingDir($this->file_name); if (file_exists($file_path)) { unlink($file_path); } }
private function SendMetadataOfAllFiles() { $files = scandir(WORKING_FOLDER); $metadataToAnswer = array(); foreach ($files as $file) { if ($file == '.' || $file == '..') { continue; } else { $metadataToAnswer[] = new FileMetaData(GetFilePathInWorkingDir($file)); } } http_response_code(200); $this->SendResponse($metadataToAnswer); }
private function CreateSingleFile($fileData, $file_path) { $file_name = basename($file_path); if ($fileData['error'] != UPLOAD_ERR_OK) { throw new FsapiException("Incorrect upload file data: " . GetFileUploadErrorExplanation($fileData['error']), 400, $file_name, $this->http_method, $this->url); } $file_path = GetFilePathInWorkingDir($file_name); if (!move_uploaded_file($fileData['tmp_name'], $file_path)) { throw new FsapiException("Failed to move uploaded file.", 500, $file_name, $this->http_method, $this->url); } }