Upload .txt file to contentful

274 views Asked by At

I am trying to upload a .txt file from computer to contentful using contentful's python api. Here is the link to documentation Below is my code

with open('/Users/p2335/Documents/Work/files/input/test.txt', 'rb') as file:
    new_upload = client.uploads(space_id).create(file)

client.assets(space_id, 'dev').create(
    'ptn2',
    {
        'fields': {
            'file': {
                'en-US': {
                    'fileName': 'rds1.txt',
                    'contentType': 'text/plain',
                    'uploadFrom': new_upload.to_link().to_json()
                }
            }
        }
    }
)

However when i check in contentful, i am not seeing the file. Below is the screenshot enter image description here What am i doing wrong here?

1

There are 1 answers

0
Robban On BEST ANSWER

I believe you also need to initiate processing of the asset with a call to asset.process(). I can't tell from the docs if the call to create is already supposed to initiate this call, but it doesn't seem that it does.