I am trying to upload a file to the path, using ShareDirectoryClient Class of Azure Python SDK.I have attached below the code and errors that I am getting.
path = "users/user11/projects/assets/fbx"
directories = path.lower().strip("/").split("/")
for directory in directories:
try:
directory_client = directory_client.get_subdirectory_client(directory)
if not directory_client.exists():
directory_client.create_directory()
except Exception as e:
print(e.args)
with directory_client.get_file_client(file_name=upload_file.name) as file_client:
file_client.upload_file(data = file_content, length=len(file_content))
print("Uploaded")
The "directory_client" is an object of ShareDirectoryClient, which is used in the above code snippet to create directories. The problem faced is, with every directory that is being created I get the below Exception.
('The specifed resource name contains invalid characters.\nRequestId:fc43b173-e01a-000c-1ae8-bd388a000000\nTime:2023-07-24T04:37:52.5072468Z\nErrorCode:InvalidResourceName',)
ClientAuthenticationError
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
ErrorCode:AuthenticationFailed authenticationerrordetail:The MAC signature found in the HTTP request 'E0eObuCq+OdHAtf4qG80kb3wprxR4vwIsDpjinnVvUM=' is not the same as any computed signature. Server used following string to sign: 'PUT.......'
And sometimes I even get ClientAuthenticationError. I'm not really sure, what is creating the problem in both the cases.
Any solutions and suggestions are open.
Thanks!
The problem I faced here is, I am trying to create directories inside File Share directly, but instead there should some directory present before trying to create a new directory.
So, I manually added a root
folder inside the File Share, that fixed my problem.
Hope this helps anyone with the same issue.