/** * TO_REFACTOR: This has nothing to do with temporary file. Should be moved in a dedicated object. */ public function getAttachedFileSize($id) { $file_info = $this->file_info_factory->getById($id); if ($file_info && $file_info->fileExists()) { return $file_info->getFilesize(); } throw new Tracker_Artifact_Attachment_FileNotFoundException(); }
/** * Return a part of the requested attachment, base64 encoded. * * @param String $session_key * @param Integer $artifact_id * @param Integer $attachment_id * @param Integer $offset * @param Integer $size * * @return String */ public function getArtifactAttachmentChunk($session_key, $artifact_id, $attachment_id, $offset, $size) { try { $current_user = $this->soap_request_validator->continueSession($session_key); $artifact = $this->getArtifactById($artifact_id, $current_user, 'getArtifactAttachmentChunk'); $file_info = $this->fileinfo_factory->getById($attachment_id); if ($file_info && $file_info->fileExists()) { $field = $file_info->getField(); if ($field->userCanRead($current_user)) { return $file_info->getContent($offset, $size); } else { return new SoapFault(invalid_field_fault, 'Permission denied: you cannot access this field'); } } else { return new SoapFault(invalid_field_fault, 'Permission denied: you cannot access this field'); } } catch (Exception $e) { return new SoapFault((string) $e->getCode(), $e->getMessage()); } }