I've seen a few posts about this, but none that completely answer my questions. I am trying to accomplish:
PRIVATE File upload via API -> Pick URLs from the response and submit via form submission API -> Files listed as links in submission view, like they appear when uploading files via the built-in Hubspot forms
I see I can retrieve a signed url via another API call, so I think I need to use that. So, my questions:
Is the signed url necessary to attach private files to a form submission?
If so, what happens when these urls expire? Does Hubspot regenerate them or do I need to create a job on my end to update them?
What data do I need to send so the form submission results list files as clickable links, instead of strings?
TBH I'm not familiar with pushing private files directly into the media manager. I have only accessed private files either through retrieving a contact property via API or uploading form submissions via API.
When I do the form submissions, I put the file into an AWS s3 bucket with my own signatures in the URL and pass that URL as a prop to the form submission file property and then delete the file from S3.
That being said.
I think what you're trying to do is, use your own form, upload the file to HS file manager with the private flag set, then pass that private file url to the submission file prop. You won't be able to do this because if the file is private the api won't be able to read it...
You need to hit the the API endpoint to grab the private file url with signature from the file api
and then use that url to pass as a prop on the contact properties...
After that is done, the contact should now have their own signed version of the file in their contact properties and you can probably delete the original file from the file manager
Hi @tjoyce@dennisedson , I know it's been a couple of years since this post, but hoping I could reopen the discussion to clarify some things? Per your suggestions, I wrote a script to make POST requests to the Hubspot API to submit a Hubspot form with an attached form by doing the following:
2. Get the signed url of the private file I just uploaded, using its `fileId` with this API endpoint
3. Submit a Hubspot form using the formId & portalId and the required form fields, including the signed url of the file I uploaded. That was via this secure form submission API endpoint
4. Delete the file I uploaded (by fileId) to the file manager using this API endpoint
Everything actually seems to be going well and it appears that the file I wanted attached to a contact, as part of the API-based form submission, is indeed there (even after the file was deleted in the file manager). However, there are 2 concerns I have
Even though the file is no longer in the file manager, but a version of it is not a part of the contact record, how exactly is the file part of the contact record now, where is it really stored, and does it have any sort of expiration time?
The file now attached to the contact record has the extension ".unknown" instead of ".pdf". I can download the file from the contact record, and manually change the extension, but this is not at all ideal. Why is the extension changed and how might I change it to remain as the original ".pdf"? For the record I don't have this issue when I set the file access to PUBLIC and use that url instead of the signed url. It seems mainly to be an issue with using the signed url. I've seen related discussions like this: https://community.hubspot.com/t5/APIs-Integrations/Forms-API-file-submitting-by-URL-incorrect-determ...
If it helps at all, here's the Node.js code I wrote to do this:
@tjoyce Sorry for the delay; didn't see your response! Thank you for the feedback. I still have a couple of questions:
1. Is there a way for us to set the expiry time for the signed url? I want the files to be available for a long period of time. 2. Is there a way to have the links show up as clickable urls in the admin, like they do when we submit via a standard Hubspot form? I can only get them to appear as strings, which is cumbersome.