Azure / azure-storage-python

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

Permissions denied when trying to upload temporary files on Windows #547

Closed logachev closed 5 years ago

logachev commented 5 years ago

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

Blob (possibly others if they have create_x_from_path() API)

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

latest Windows OS

What problem was encountered?

BlockBlobService.create_blob_from_path() fails with Permissions denied on Windows when publishing file, created by tempfile library.

Have you found a mitigation/solution?

Please see this thread: https://stackoverflow.com/questions/15169101/how-to-create-a-temporary-file-that-can-be-read-by-a-subprocess

def temp_opener(name, flag, mode=0o777):
    return os.open(name, flag | os.O_TEMPORARY, mode)

with open(f.name, "rb", opener=temp_opener) as f:

instead of

with open(f.name, "rb") as f:

Note: for table service, please post the issue here instead: https://github.com/Azure/azure-cosmosdb-python.

zezha-msft commented 5 years ago

Hi @logachev, thanks for reaching out!

Feel free to implement your own version of create_x_from_path and invoke create_x_from_stream subsequently.