1<?php 2 3declare(strict_types=1); 4 5namespace Sabre\DAV; 6 7/** 8 * File class. 9 * 10 * This is a helper class, that should aid in getting file classes setup. 11 * Most of its methods are implemented, and throw permission denied exceptions 12 * 13 * @copyright Copyright (C) fruux GmbH (https://fruux.com/) 14 * @author Evert Pot (http://evertpot.com/) 15 * @license http://sabre.io/license/ Modified BSD License 16 */ 17abstract class File extends Node implements IFile 18{ 19 /** 20 * Replaces the contents of the file. 21 * 22 * The data argument is a readable stream resource. 23 * 24 * After a successful put operation, you may choose to return an ETag. The 25 * etag must always be surrounded by double-quotes. These quotes must 26 * appear in the actual string you're returning. 27 * 28 * Clients may use the ETag from a PUT request to later on make sure that 29 * when they update the file, the contents haven't changed in the mean 30 * time. 31 * 32 * If you don't plan to store the file byte-by-byte, and you return a 33 * different object on a subsequent GET you are strongly recommended to not 34 * return an ETag, and just return null. 35 * 36 * @param string|resource $data 37 * 38 * @return string|null 39 */ 40 public function put($data) 41 { 42 throw new Exception\Forbidden('Permission denied to change data'); 43 } 44 45 /** 46 * Returns the data. 47 * 48 * This method may either return a string or a readable stream resource 49 * 50 * @return mixed 51 */ 52 public function get() 53 { 54 throw new Exception\Forbidden('Permission denied to read this file'); 55 } 56 57 /** 58 * Returns the size of the file, in bytes. 59 * 60 * @return int 61 */ 62 public function getSize() 63 { 64 return 0; 65 } 66 67 /** 68 * Returns the ETag for a file. 69 * 70 * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. 71 * The ETag is an arbitrary string, but MUST be surrounded by double-quotes. 72 * 73 * Return null if the ETag can not effectively be determined 74 * 75 * @return string|null 76 */ 77 public function getETag() 78 { 79 return null; 80 } 81 82 /** 83 * Returns the mime-type for a file. 84 * 85 * If null is returned, we'll assume application/octet-stream 86 * 87 * @return string|null 88 */ 89 public function getContentType() 90 { 91 return null; 92 } 93} 94