def create_file(self): """ Called when this is a new file; will create a new Content initialized with the correct content """ is_temporary = self._file_name.startswith( ".~") or self._file_name.startswith("~") try: with self._session.no_autoflush: file = self._api.create( filename=self._file_name, content_type_slug=content_type_list.File.slug, workspace=self._workspace, parent=self._parent, is_temporary=is_temporary, do_save=False, ) self._api.update_file_data( file, self._file_name, util.guessMimeType(self._file_name), self._file_stream.read(), ) except TracimException as exc: raise DAVError(HTTP_FORBIDDEN) from exc self._api.save(file, ActionDescription.CREATION)
def create_file(self): """ Called when this is a new file; will create a new Content initialized with the correct content """ is_temporary = self._file_name.startswith('.~') or self._file_name.startswith('~') try: with self._session.no_autoflush: file = self._api.create( filename=self._file_name, content_type_slug=content_type_list.File.slug, workspace=self._workspace, parent=self._parent, is_temporary=is_temporary, do_save=False, ) self._api.update_file_data( file, self._file_name, util.guessMimeType(self._file_name), self._file_stream.read() ) except TracimException as exc: raise DAVError(HTTP_FORBIDDEN) from exc self._api.save(file, ActionDescription.CREATION)
def getContentType(self): # (mimetype, _mimeencoding) = mimetypes.guess_type(self.path) # print "mimetype(%s): %r, %r" % (self.path, mimetype, _mimeencoding) # if not mimetype: # mimetype = "application/octet-stream" # print "mimetype(%s): return %r" % (self.path, mimetype) # return mimetype return util.guessMimeType(self.path)
def getContentType(self): if not os.path.isfile(self.filePath): return "text/html" # (mimetype, _mimeencoding) = mimetypes.guess_type(self.filePath) # if not mimetype: # mimetype = "application/octet-stream" # return mimetype return util.guessMimeType(self.filePath)
def getContentType(self): if self.isCollection: return None # (mimetype, _mimeencoding) = mimetypes.guess_type(self.path) # if not mimetype: # return "application/octet-stream" # return mimetype return util.guessMimeType(self.path)
def update_file(self): """ Called when we're updating an existing content; we create a new revision and update the file content """ with new_revision(self._content): self._api.update_file_data( self._content, self._file_name, util.guessMimeType(self._content.file_name), self._file_stream.read()) self._api.save(self._content, ActionDescription.EDITION)
def update_file(self): """ Called when we're updating an existing content; we create a new revision and update the file content """ with new_revision(self._content): self._api.update_file_data( self._content, self._file_name, util.guessMimeType(self._content.file_name), self._file_stream.read() ) self._api.save(self._content, ActionDescription.REVISION)
def update_file(self): """ Called when we're updating an existing content; we create a new revision and update the file content """ with new_revision( session=self._session, content=self._content, tm=transaction.manager, ): self._api.update_file_data( self._content, self._file_name, util.guessMimeType(self._content.file_name), self._file_stream.read()) self._api.save(self._content, ActionDescription.REVISION)
def create_file(self): """ Called when this is a new file; will create a new Content initialized with the correct content """ is_temporary = self._file_name.startswith( '.~') or self._file_name.startswith('~') file = self._api.create(content_type=ContentType.File, workspace=self._workspace, parent=self._parent, is_temporary=is_temporary) self._api.update_file_data(file, self._file_name, util.guessMimeType(self._file_name), self._file_stream.read()) self._api.save(file, ActionDescription.CREATION)
def update_file(self): """ Called when we're updating an existing content; we create a new revision and update the file content """ try: with new_revision(session=self._session, content=self._content, tm=transaction.manager): self._api.update_file_data( self._content, self._file_name, util.guessMimeType(self._content.file_name), self._file_stream.read(), ) except TracimException as exc: raise DAVError(HTTP_FORBIDDEN) from exc self._api.save(self._content, ActionDescription.REVISION)
def update_file(self): """ Called when we're updating an existing content; we create a new revision and update the file content """ try: with new_revision( session=self._session, content=self._content, tm=transaction.manager, ): self._api.update_file_data( self._content, self._file_name, util.guessMimeType(self._content.file_name), self._file_stream.read() ) except TracimException as exc: raise DAVError(HTTP_FORBIDDEN) from exc self._api.save(self._content, ActionDescription.REVISION)
def create_file(self): """ Called when this is a new file; will create a new Content initialized with the correct content """ is_temporary = self._file_name.startswith( '.~') or self._file_name.startswith('~') with self._session.no_autoflush: file = self._api.create( filename=self._file_name, content_type_slug=content_type_list.File.slug, workspace=self._workspace, parent=self._parent, is_temporary=is_temporary, do_save=False, ) self._api.update_file_data(file, self._file_name, util.guessMimeType(self._file_name), self._file_stream.read()) self._api.save(file, ActionDescription.CREATION)
def create_file(self): """ Called when this is a new file; will create a new Content initialized with the correct content """ is_temporary = self._file_name.startswith('.~') or self._file_name.startswith('~') file = self._api.create( content_type=ContentType.File, workspace=self._workspace, parent=self._parent, is_temporary=is_temporary ) self._api.update_file_data( file, self._file_name, util.guessMimeType(self._file_name), self._file_stream.read() ) self._api.save(file, ActionDescription.CREATION)
def getContentType(self): return util.guessMimeType(self.path)