Reading Files in Invenio-Files-Record

Hi I was exploring Invenio-Files-Record module for the user to access the content of the files without having to download the files locally. My goal is for the user to process on the file without actually downloading it , just by calling the invenio db methods and work on it.

I looked through the content of uploading and retrieving files to the bucket, but none of these has methods to actually read the content of the file, can someone please help on how do actually read or access the content to the file?

I have tried something like

files = Record(record)
fileobj = record.files[‘hello.txt’]

with‘rb’) as file:
file_content =‘utf-8’)


file_content =‘utf-8’)

but none of these seems to be working as ‘ObjectVersion’ object has no attribute ‘storage’.

Can someone please help?

to access the file, you need to do something different: record.files gives you an iterator, where each item is just a representation of the real file.

If you get an ObjectVersion, then you can try to do the following:

object_version = record.files[‘hello.txt’]
fileobj = object_version.file

with‘rb’) as file:
    file_content =‘utf-8’)