/** * Deletes a file. * * Called when this component receives an HTTP DELETE request to * /zip/$a/$b/$c/$file. * * @param string $hash The hash of the file which should be deleted. */ public function deleteZip($callName, $input, $params = array()) { $path = array(self::getBaseDir(), $params['a'], $params['b'], $params['c'], $params['file']); $filePath = implode('/', array_slice($path, 0)); if (strlen($filePath) > 0 && file_exists($this->config['DIR']['files'] . '/' . $filePath)) { // after the successful deletion, we want to return the file data $file = new File(); $file->setAddress($filePath); $file->setFileSize(filesize($this->config['DIR']['files'] . '/' . $filePath)); $file->setHash(sha1_file($this->config['DIR']['files'] . '/' . $filePath)); $file->setMimeType("application/zip"); // removes the file unlink($this->config['DIR']['files'] . '/' . $filePath); // the removing/unlink process failed, if the file still exists. if (file_exists($this->config['DIR']['files'] . '/' . $filePath)) { return Model::isProblem(new File()); } // the file is removed return Model::isCreated($file); } else { // file does not exist return Model::isProblem(new File()); } }