We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Dec 8, 2021 4:48 PM - edited Dec 9, 2021 6:36 AM
Regarding the Hubspot Files API:
I am now trying to get the replace function working as documented here: https://developers.hubspot.com/docs/api/files/files
I am able to replace a jpg with another jpg using the Replace API call.
I want to replace a jpg wtih a webp file, which should be fine as they both have the same type (IMG). But when I upload the file (test_file.webp) with a .webp file extension I get a 400 error (weird error number, would 415 make more sense).
But, if I upload the exact same webp file, but put the file name as test_file.jpg it works fine! Yes the binary contents are webp, but the file extension is .jpg. When I view the file in the Files portal, it shows up with a .jpg extension, but displays fine.
I get the same result using both of these endpoints:
PUT /files/v3/files/{fileId}
POST /filemanager/api/v3/files/:file_id/replace
Why can't I replace an IMG file with another IMG file? Is this a bug? I mean I am able to rename a file, and I don't have to change the references in my Landing pages... so the system should be able to handle a different extension if the type doesn't change.
Dec 21, 2021 7:38 AM
The main reason is that webp files are way smaller. In my testing around 5-10x small, and when rendered in a webpage. Before creating this upload tool we were servring up an 8MB homepage, and have cut that by more than half after switching to webp.
Dec 9, 2021 3:06 PM
@Sheamus ,
100% not the answer to your question, but why not just let HubSpot do the conversion for you?
If the browser supports webp, HubSpot will convert it. Link to the doc for reference
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |