APIs & Integrations

henrikra
Member

How to create signed url redirect for uploaded private image?

I am trying to make custom form with image upload. The form sends data to my backend endpoint. The endpoint uses `/filemanager/api/v3/files/upload` to upload the images first to HubSpot. Also I want the images to be private. Then I would like to submit result with `https://api.hsforms.com/submissions/v3/integration/submit/:portalId/:formGuid`.

 

But the problem is that when adding image urls which I got back from `/filemanager/api/v3/files/upload` to form submit endpoint the url cannot be opened because they are private.

 

This ok because I should use this https://legacydocs.hubspot.com/docs/methods/form-integrations/v1/uploaded-files/signed-url-redirect to get signed url and then I can open the images. The url should have fileId, portalId, sign, conversionId, and filename. But I can only get fileId, portalId from the response of `/filemanager/api/v3/files/upload`.

 

So my main question is how can I get sign, conversionId, and filename? The documentation does not mention anything about these 3 properties. Can you help me?

7 Replies 7
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

How to create signed url redirect for uploaded private image?

@henrikra - I see, thank you for the clarification.

When submitting files through the form api, you just need to include a fully qualified url to the source (including domain name). So your frontend form would save the file to your server (or something like amazon s3) then in the forms API you would pass that file field with the value of that URL. Although the form is using file upload, the api only expects a string which represents the location of the image. 

 

So, in your last step where you submit the form you would add the url to the fields props

  "fields": [
    {
      "name": "customer_upload",
      "value": "https://domain.com/theirimage.jpg"
    }
  ],

 

It looks like in step 4 you might be trying to use the hubspot file manager as the storage device. I don't remember if that API endpoint returns the full location of the file URL but I think that's what you need to pass in the "value" field.

henrikra
Member

How to create signed url redirect for uploaded private image?

Did get chance to check my reply tjoyce?

0 Upvotes
DRidenhour
Member

How to create signed url redirect for uploaded private image?

@tjoyce I'm running into the exact same problem.  I can upload private files just fine, but I cannot figure out how to successfully send final urls (multiple urls, in some cases) to the form.  Thank you!

0 Upvotes
henrikra
Member

How to create signed url redirect for uploaded private image?

Yeah I noticed the same that it is enough just to give string url to the form api to file fields. That is not the issue.

 

And yes you are correct I would like to use hubspot file api to upload file since it does exactly what I want + I want the files to be private, not public.

 

But I noticed that if I open form submission from hubspot console and see what values the fields got the file field has clickable link only if Hubspot file api was used. And I would like to that clickable link always work even with private files. And that brings to my original question: how can I create signed url for the private image that was uploaded to Hubspot api. Signed-url creates me link in which I can access the private image right? But seems like there is no way to create that signed url by yourself 😕

0 Upvotes
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

How to create signed url redirect for uploaded private image?

@henrikra - All you have to do is fetch the contact from the api that you're trying to retrieve a file for. Then look at the property you used for the file upload... The initial request of the contact property will give you the complete and exact URL you need to pass... you don't have to build this URL.

I think it will be clear to you if you navigate to a contact that has submitted the form with a file. If you look at that contact's properties, and head to the file upload property, you will see the complete signed URL there. So basically you need to just fetch this contact property from the API and pass that as the signed URL.

henrikra
Member

How to create signed url redirect for uploaded private image?

Hmm in my case the form has not submitted yet.

 

Let me explain more

  • first I create form schema in Hubspot. (form includes one file upload field + some other text fields)
  • then I create custom form UI for my website (has file upload input + some text fields)
  • then I have custom backend with endpoint which I call from my form UI
  • in that endpoint (which I have in my backend) I am calling first `/filemanager/api/v3/files/upload` to first upload the files to hubspot.
  • then my plan was to call (still in my backend) `https://api.hsforms.com/submissions/v3/integration/submit/:portalId/:formGuid` to actually make form submit with files etc

 

So can you tell me where I am doing it wrong? Which Hubspot APIs (and in which order) should I call when I have custom form UI with file upload and I want to submit form data to Hubspot.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

How to create signed url redirect for uploaded private image?

Hi @henrikra 

Thanks for the detailed question. 

Bringing in @tjoyce to see if he has some ideas.