# Using Python PIL to parse .png uploaded to fieldType: "file" property

**URL:** <https://community.hubspot.com/t/using-python-pil-to-parse-png-uploaded-to-fieldtype-file-property/80399>\
**Category:** APIs & Integrations\
**Tags:** python, companies, forms, professional\
**Created:** [May 2, 2023, 3:10pm UTC](https://community.hubspot.com/t/using-python-pil-to-parse-png-uploaded-to-fieldtype-file-property/80399 "2023-05-02T15:10:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asclepius](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@Asclepius](https://community.hubspot.com/u/Asclepius)\
**Post date:** [May 2, 2023, 3:10pm UTC](https://community.hubspot.com/t/using-python-pil-to-parse-png-uploaded-to-fieldtype-file-property/80399/1 "2023-05-02T15:10:01Z")

</div>

Hey,

I’m trying to automate the creation of a “branding” object in Django, which includes parsing a .png uploaded to Hubspot through a Form-Submission.

This is what I have right now:

import requests

from PIL import Image

def hs\_parse\_img(url):

```
image = Image.open(requests.get(url, stream=True).raw)

return image

```

hs\_parse\_img(

```
"https://api-na1.hubspot.com/form-integrations/v1/uploaded-files/signed-url-redirect/......"

```

)

When I try to run the script I get the following error:  
PIL.UnidentifiedImageError: cannot identify image file \<\_io.BytesIO object at …\>  
Is it even possible to utilize fieldType: “file” properties in this way?  
Thanks

---

<div class="post-metadata">

**Author:** ![Asclepius](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@Asclepius](https://community.hubspot.com/u/Asclepius)\
**Post date:** [May 8, 2023, 10:15am UTC](https://community.hubspot.com/t/using-python-pil-to-parse-png-uploaded-to-fieldtype-file-property/80399/2 "2023-05-08T10:15:34Z")

</div>

Finally fixed this, after being in contact with HS Support.  
The Problem was that my Private App didn’t have the correct Scope (forms-uploaded-files) / that I didn’t pass the headers argument.  
This works for me:

HUBAPI\_TOKEN = “Bearer INSERT PAT TOKEN HERE”

url\_1 = “[https://api-na1.hubspot.com/form-integrations/v1/uploaded-files/signed-url-redirect/](https://api-na1.hubspot.com/form-integrations/v1/uploaded-files/signed-url-redirect/)…”

def hs\_get\_file(url, headers​😞

```
auth = {"Authorization": headers}

response = requests.get(url, headers=auth)

return response

```

print(hs\_get\_file(url\_1, HUBAPI\_TOKEN))
