def delete(self, path): blobs = self._list_blob_or_chunks(path) if not blobs: raise FileNotFound('File %s does not exist.' % path) for blob in blobs: blob.delete()
def read(self, filepath): try: return self._ssh_client.get_text_content( osp.join(self.remote_path, filepath)) except IOError as err: if err.errno == ENOENT: raise FileNotFound('File %s does not exist' % filepath) else: raise
def read(self, filepath): """ Read content of filepath and return it as a string. :param filepath: Path in S3 bucket. :return: Content of the file. :rtype: str :raises FileNotFound: If filepath doesn't exist. """ try: response = self.s3_client.get_object(Bucket=self._bucket, Key=filepath) return response['Body'].read() except self.s3_client.exceptions.NoSuchKey: raise FileNotFound('%s does not exist' % filepath)
def read(self, filepath): """ Read content from a file. :param filepath: relative path to a file with status. :type filepath: str :return: Content of the file. :rtype: str :raises FileNotFound: if filepath doesn't exist on the destination. """ obj = self._bucket_obj.blob( filepath ) try: return obj.download_as_string() except NotFound as err: raise FileNotFound(err)