APIs & Integrations

Sheamus
参加者

Unable to replace JPG with WebP file if I use the .webp file extension

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.

0 いいね!
2件の返信
Sheamus
参加者

Unable to replace JPG with WebP file if I use the .webp file extension

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.

0 いいね!
dennisedson
HubSpot製品開発チーム
HubSpot製品開発チーム

Unable to replace JPG with WebP file if I use the .webp file extension

@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

0 いいね!