Ad
Read-only File System: 'data.json': IOError In Aws Lambda Function
I am trying to read data from PDF stored in S3 bucket, convert it to text and then dump these text into json file.
Finally I want to upload this json file to elastic search for indexing.
I have written below code snippet for doing this:
with open('data.json','w') as f:
json.dump(doc,f)
dataj=json.load(f)
doc_data=dataj[:]
doc
is the text which I have extracted using pdfminer.
when executing this code I'm getting below error.
[Errno 30] Read-only file system: 'data.json': IOError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 56, in lambda_handler
raise e
IOError: [Errno 30] Read-only file system: 'data.json'.
Someone please help me in finding what I'm doing wrong here.
Ad
Answer
You're trying to write a file where is not permitted.
Lambda currently only supports writing files to the /tmp directory.
with open('/tmp/data.json','w') as f:
json.dump(doc,f)
dataj=json.load(f)
doc_data=dataj[:]
Ad
source: stackoverflow.com
Related Questions
- → I can't convert Json to string [OctoberCms]
- → Uncaught TypeError Illegal invocation when send FormData to ajax
- → Laravel Send URL with JSON
- → how to write react component to construct HTML DOM
- → AJAX folder path issue
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel - bindings file for repositories
- → Good solution to work with rest-api like SPA with redux?
- → getting the correct record in Angular with a json feed and passed data
- → Transformer usage on laravel/dingo API
- → Google options Page not saving - Javascript
- → Ember.js JSON API confusion
- → How can I query Firebase for an equalTo boolean parameter?
Ad