118 return array_key_exists($key, $this->properties);
129 return $this->properties[$key];
159 return $this->properties[
'identifier_hash'];
189 if ($this->deleted) {
190 throw new \RuntimeException(
'File has been deleted.', 1329821480);
192 return $this->properties[
'size'] ?: array_pop($this->
getStorage()->getFileInfoByIdentifier($this->
getIdentifier(), array(
'size')));
211 if ($this->deleted) {
212 throw new \RuntimeException(
'File has been deleted.', 1329821481);
214 return $this->
getStorage()->hashFile($this,
'sha1');
224 if ($this->deleted) {
225 throw new \RuntimeException(
'File has been deleted.', 1329821487);
237 if ($this->deleted) {
238 throw new \RuntimeException(
'File has been deleted.', 1329821488);
251 $extension = strtolower($pathinfo[
'extension']);
262 return $this->properties[
'mime_type'] ?: array_pop($this->
getStorage()->getFileInfoByIdentifier($this->
getIdentifier(), array(
'mimetype')));
282 if (!$this->properties[
'type']) {
284 list($fileType) = explode(
'/', $mimeType);
285 switch (strtolower($fileType)) {
287 $this->properties[
'type'] = self::FILETYPE_TEXT;
290 $this->properties[
'type'] = self::FILETYPE_IMAGE;
293 $this->properties[
'type'] = self::FILETYPE_AUDIO;
296 $this->properties[
'type'] = self::FILETYPE_VIDEO;
301 $this->properties[
'type'] = self::FILETYPE_APPLICATION;
304 $this->properties[
'type'] = self::FILETYPE_UNKNOWN;
307 return (
int)$this->properties[
'type'];
320 if ($this->deleted) {
321 throw new \RuntimeException(
'File has been deleted.', 1329821479);
323 return $this->
getStorage()->getFileContents($this);
335 if ($this->deleted) {
336 throw new \RuntimeException(
'File has been deleted.', 1329821478);
338 $this->
getStorage()->setFileContents($this, $contents);
353 if ($this->storage === NULL) {
354 throw new \RuntimeException(
'You\'re using fileObjects without a storage.', 1381570091);
367 if ($this->deleted) {
383 $this->properties[
'storage'] = $storage->
getUid();
407 $combinedIdentifier = $this->properties[
'storage'] .
':' . $this->
getIdentifier();
411 return $combinedIdentifier;
419 public function delete() {
421 return $this->
getStorage()->deleteFile($this);
431 $this->deleted = TRUE;
452 if ($this->deleted) {
453 throw new \RuntimeException(
'File has been deleted.', 1329821482);
455 return $this->
getStorage()->renameFile($this, $newName);
468 public function copyTo(
Folder $targetFolder, $targetFileName = NULL, $conflictMode =
'renameNewFile') {
469 if ($this->deleted) {
470 throw new \RuntimeException(
'File has been deleted.', 1329821483);
472 return $targetFolder->
getStorage()->copyFile($this, $targetFolder, $targetFileName, $conflictMode);
485 public function moveTo(
Folder $targetFolder, $targetFileName = NULL, $conflictMode =
'renameNewFile') {
486 if ($this->deleted) {
487 throw new \RuntimeException(
'File has been deleted.', 1329821484);
489 return $targetFolder->
getStorage()->moveFile($this, $targetFolder, $targetFileName, $conflictMode);
505 if ($this->deleted) {
508 return $this->
getStorage()->getPublicUrl($this, $relativeToCurrentScript);
523 if ($this->deleted) {
524 throw new \RuntimeException(
'File has been deleted.', 1329821486);
526 return $this->
getStorage()->getFileForLocalProcessing($this, $writable);
updateProperties(array $properties)
static canBeInterpretedAsInteger($var)
setIdentifier($identifier)
static pathinfo($path, $options=NULL)
getNameWithoutExtension()
getForLocalProcessing($writable=TRUE)
setStorage(ResourceStorage $storage)
getPublicUrl($relativeToCurrentScript=FALSE)
moveTo(Folder $targetFolder, $targetFileName=NULL, $conflictMode='renameNewFile')
copyTo(Folder $targetFolder, $targetFileName=NULL, $conflictMode='renameNewFile')
const FILETYPE_APPLICATION