'error reading and writing files in cloud function
I am reading file from SharePoint and writitng in GCS bucket but when I run the function it gives me error "Error [Errno 30] Read-only file system: 'test.xlsx'" here is the code
response = File.open_binary(ctx,location/file )
blob = bucket.blob('/sharepoint/' + doc)
print('connection')
with open("test.xlsx", "wb") as local_file:
blob.upload_from_file(local_file)
local_file.close()
please help if anyone know the solution of this error
Solution 1:[1]
Doing this open("test.xlsx", "wb") destroys the file. The file is also locked while open which causes the error message.
Change your code to open the file in read mode:
with open("test.xlsx", "rb") as local_file:
blob.upload_from_file(local_file)
local_file.close()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Hanley |
