Azure / azure-storage-python

Microsoft Azure Storage Library for Python
https://azure-storage.readthedocs.io
MIT License
338 stars 240 forks source link

Generated sas token for specific file does not seem to work. #494

Closed williexu closed 6 years ago

williexu commented 6 years ago

Which service(blob, file, queue) does this issue concern?

file

Which version of the SDK was used? Please provide the output of pip freeze.

v1.3.1

What problem was encountered?

I can't generate a working file sas token:

>>> client.generate_file_shared_access_signature('wilxshare', file_name='stuff.txt', directory_name='.', permission=file.FilePermissions(read=True, create=True), expiry='2018-08-27T20:34Z')
'se=2018-08-27T20%3A34Z&sp=rc&sv=2018-03-28&sr=f&sig=...'

This token does not work when I atempt to download(I'm using CLI): az storage file download -s wilxshare --account-name wilxremove -p stuff.txt --dest ..\temp\file.txt --sas-token "se=2018-08-27T20%3A34Z&sp=rc&sv=2018-03-28&sr=f&sig=..."

If this is a user error, please let me know.

Have you found a mitigation/solution?

Using a sas-token generated for the share allows me to download my files. However, this does not allow fine-grained access for particular files.

zezha-msft commented 6 years ago

Hi @williexu, why did you put '.' for directory_name? Please pass None if your file is in the root directory.

williexu commented 6 years ago

@zezha-msft thanks for the help. I can confirm that works, would still recommend adding documentation for None if there is no directory as others may make the same mistake I made.

zezha-msft commented 6 years ago

@williexu Ok! Will do!