diff options
Diffstat (limited to 'lib/private/connector')
-rw-r--r-- | lib/private/connector/sabre/exception/entitytoolarge.php | 22 | ||||
-rw-r--r-- | lib/private/connector/sabre/exception/unsupportedmediatype.php | 22 | ||||
-rw-r--r-- | lib/private/connector/sabre/file.php | 16 |
3 files changed, 59 insertions, 1 deletions
diff --git a/lib/private/connector/sabre/exception/entitytoolarge.php b/lib/private/connector/sabre/exception/entitytoolarge.php new file mode 100644 index 00000000000..2bda51f2f3e --- /dev/null +++ b/lib/private/connector/sabre/exception/entitytoolarge.php @@ -0,0 +1,22 @@ +<?php + +/** + * Entity Too Large + * + * This exception is thrown whenever a user tries to upload a file which exceeds hard limitations + * + */ +class OC_Connector_Sabre_Exception_EntityTooLarge extends Sabre_DAV_Exception { + + /** + * Returns the HTTP status code for this exception + * + * @return int + */ + public function getHTTPCode() { + + return 413; + + } + +} diff --git a/lib/private/connector/sabre/exception/unsupportedmediatype.php b/lib/private/connector/sabre/exception/unsupportedmediatype.php new file mode 100644 index 00000000000..95d6a8cc651 --- /dev/null +++ b/lib/private/connector/sabre/exception/unsupportedmediatype.php @@ -0,0 +1,22 @@ +<?php + +/** + * Unsupported Media Type + * + * This exception is thrown whenever a user tries to upload a file which holds content which is not allowed + * + */ +class OC_Connector_Sabre_Exception_UnsupportedMediaType extends Sabre_DAV_Exception { + + /** + * Returns the HTTP status code for this exception + * + * @return int + */ + public function getHTTPCode() { + + return 415; + + } + +} diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 037dba7f37b..667f7407f75 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -98,7 +98,21 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D throw new Sabre_DAV_Exception(); } } catch (\OCP\Files\NotPermittedException $e) { - throw new Sabre_DAV_Exception_Forbidden(); + // a more general case - due to whatever reason the content could not be written + throw new Sabre_DAV_Exception_Forbidden($e->getMessage()); + + } catch (\OCP\Files\EntityTooLargeException $e) { + // the file is too big to be stored + throw new OC_Connector_Sabre_Exception_EntityTooLarge($e->getMessage()); + + } catch (\OCP\Files\InvalidContentException $e) { + // the file content is not permitted + throw new OC_Connector_Sabre_Exception_UnsupportedMediaType($e->getMessage()); + + } catch (\OCP\Files\InvalidPathException $e) { + // the path for the file was not valid + // TODO: find proper http status code for this case + throw new Sabre_DAV_Exception_Forbidden($e->getMessage()); } // rename to correct path |