protected function delete_stored_file(\Orm\Model $obj) { if (conf('upload.storageType') == 'normal') { return; } if ($this->_is_tmp && \Model_File::get4name($obj->name)) { return; } if (conf('upload.storageType') == 'S3') { return \Site_S3::delete($obj->name, 'img') && \Site_S3::delete($obj->name, 'file'); } if (!($file_bin = \Model_FileBin::get4name($obj->name))) { return; } return $file_bin->delete(); }
protected function delete_file($filename, $storage_type = 'normal', $is_delete_raw_file_only = false, $is_delete_with_storage_data = true) { $filename_excluded_prefix = str_replace($this->options['filename_prefix'], '', $filename); $file_path = $this->get_upload_path($filename_excluded_prefix); $success = is_file($file_path) && unlink($file_path); if ($success && !$is_delete_raw_file_only) { foreach ($this->options['image_versions'] as $version => $options) { if (!empty($version)) { $varsion_file = $this->get_upload_path($filename_excluded_prefix, $version); if (is_file($varsion_file)) { unlink($varsion_file); } } } } if (!$is_delete_with_storage_data) { return $success; } if ($storage_type == 'db') { if ($file_bin = Model_FileBin::get4name($filename)) { $success = (bool) $file_bin->delete(); } } elseif ($storage_type == 'S3') { $success = (bool) Site_S3::delete($filename, $this->options['upload_type']); } return $success; }