:param folder:
:return: None or raises an exception
"""
+ folder = folder.rstrip("/")
try:
self.fs.upload_from_stream(folder, BytesIO(), metadata={"type": "dir"})
except errors.FileExists: # make it idempotent
:param dst: destination directory
:return: None or raises and exception
"""
+ dst = dst.rstrip("/")
+ src = src.rstrip("/")
+
try:
dst_cursor = self.fs.find(
{"filename": {"$regex": "^{}(/|$)".format(dst)}}, no_cursor_timeout=True
:return: True, False
"""
f = storage if isinstance(storage, str) else "/".join(storage)
+ f = f.rstrip("/")
cursor = self.fs.find({"filename": f})
"Multiple files found", http_code=HTTPStatus.INTERNAL_SERVER_ERROR
)
- print(requested_file.metadata)
+ self.logger.debug("Entry {} metadata {}".format(f, requested_file.metadata))
# if no special mode is required just check it does exists
if not mode:
:return: file size
"""
f = storage if isinstance(storage, str) else "/".join(storage)
+ f = f.rstrip("/")
cursor = self.fs.find({"filename": f})
:return: None
"""
f = path if isinstance(path, str) else "/".join(path)
+ f = f.rstrip("/")
if type(compressed_object) is tarfile.TarFile:
for member in compressed_object.getmembers():
file_type = "dir"
metadata = {"type": file_type, "permissions": member.mode}
+ member.name = member.name.rstrip("/")
+ self.logger.debug("Uploading {}".format(member.name))
self.fs.upload_from_stream(
f + "/" + member.name, stream, metadata=metadata
)
file_type = "file"
metadata = {"type": file_type}
+ member.filename = member.filename.rstrip("/")
- print("Now uploading...")
- print(f + "/" + member.filename)
+ self.logger.debug("Uploading {}".format(member.filename))
self.fs.upload_from_stream(
f + "/" + member.filename, stream, metadata=metadata
)
"""
try:
f = storage if isinstance(storage, str) else "/".join(storage)
+ f = f.rstrip("/")
if "b" in mode:
return GridByteStream(f, self.fs, mode)
"""
try:
f = storage if isinstance(storage, str) else "/".join(storage)
+ f = f.rstrip("/")
files = []
dir_cursor = self.fs.find({"filename": f})
"""
try:
f = storage if isinstance(storage, str) else "/".join(storage)
+ f = f.rstrip("/")
file_cursor = self.fs.find({"filename": f})
found = False