[New Feature] File option on API Connector plugin

@keith Yes sounds like a bug then. To help determine the extent of the problem …
Experiment 1 - alter the params on the second call
Experiment 2 - serve different content on the second call

Hi @marca, any way we could also have an API call to POST File? Especially for images? Base64 adds Overhead and it would be nice to be able to POST an image / file once uploaded via API.

Thank you

Hey @marca, I did pass this along to Support. Thanks for your assistance.

My current workaround is to use Rebrandly as a “redirect” mechanism. (Give listing a Rebrandly URL which points directly to the .ics file URL in s3. Update the destination of the Rebrandly link when the file changes.) … but it would just be far easier if we could simply serve up files directly from Bubble (without loading a page, which is the source of this issue, fundamentally).

Best regards,
Keith

gilles, I believe you can already do this, if I am not mistaken. See my attachment. This is geared toward the Wrike Api (a project management software) but I believe it should work for any API. They needed a Base64 encoded image as well.

Set the body type to “Form-data” then the parameter gives you the option to add a value that is an image. Check off Send file and it should work! Note the content type I have in my header - octet-stream. That’s important as well. The other two items (X-File-Name and X-requested) I don’t think are important…

P.S. If you want to be able to dynamically add an image, uncheck Private.

P.S.S. I named my parameter key “data-binary” since that’s what Wrike recommended.

2 Likes

Thx @w.fly - you noted “they needed a Base64 encoded as well” - does this procedure/steps automatically POST encoded Base64? By default, I’ll POST my image via base64, but if there’s a way to not send it in base64 format, I would prefer it to be that. Base64 adds extra overhead ( ~30%) vs just sending the raw image. Trying to save my customers time when they’re uploading from their mobile devices.

Thank you -
G

Update: support doesn’t quite grasp what I’m going on about. Sigh.

In case it’s not clear: Sometimes, you just need the URL to a static object like a file (be it an image, pdf, ics or whatever mime type you might think of). But in the current bubble environment, if you rely on external APIs to generate such things (as one must), you will NEVER have a persistent URL for such a thing.

But even that is somewhat beside the point as you can’t at present build a true redirection tool. You can redirect a user’s browser, but you can’t do (in a dynamic, programmatic, non-user-authenticated, scalable way) true redirects or file serves connected to your domain.

Like I can’t create alias:

https://mydomain/todays-best-cat-photo

Which resolves in all cases to “an actual jpeg that resides at some other URI”.

Sorry for not fully understanding your feature request. Our response was based on your preferred workaround methods. A test page / workflow with an example that shows the current limitation will be very helpful to explore what features would have to be added to support your exact use case.

Hi @neerja,

I can provide a simplified(ish) example of why this issue arises and why workarounds do not seem to exist. Can create a video that explains.

Best Regards,
Keith

I believe so - However, I don’t believe there is an option to not send it by base64. I don’t have enough experience unfortunately with the matter. I’m sure there is a way to do it, but as with most advanced topics in Bubble, the solutions are sometimes way more complicated than expected :confused:

1 Like

Hi @marca

we are receiving the file correctly but the name is something like this [1], which makes the file almost unusable because the content type is unknown and since the file name cannot be set it cannot be inferred.

Could you please help us understand how to return the file name and the content type?

Kind Regards
Mario

[1]
https://s3.amazonaws.com/appforest_uf/xxxxxxxxxx4ssssssssss/invoke%3Fapi-version%3D2016-06-01%26sp%3D%2Ftriggers%2Fmanual%2Frun%26sv%3D1.0%26sig%3DugYtHPDJ1RgbwFkWk0Rk9WwehdMpE-abcB5aBWfhghw

Hey

I need to send a file via API and I’m lost.

This is suggested format:

56%20PM

My POST API call body looks like this:

{
“attachment”: {
“file”: {
“path”: “s3.amazonaws.com/appforest_uf/f1541769379305x351455504307523400/1.png”,
“filename”: “cv1.pdf”,
“content_type”: null
}
}
}

I assume the “path” is wrong. Is there a different format I need to have the file in? (The rest should be set up correctly as I have it working across different API calls.)

try with:
{
“attachment”: “s3.amazonaws.com/appforest_uf/f1541769379305x351455504307523400/1.png
}

Thanks for the suggestion. Unfortunately also not working. So does that mean the path or in your case attachment format is right? I have been struggling to send files anywhere.

{
“attachment”: “https://s3.amazonaws.com/appforest_uf/f1541769379305x351455504307523400/1.png
}

where attachment is the name of the field of type file in the thing.

Feel free to PM me if you want to get on a quick Skype call :slight_smile:

Mario

Hi @keith, just wondering if you can share how you set up your API to build the calendar files? I’d like to do the same (creating JSON files instead of calendar files) but can’t figure out the correct setup in the API connector.

@marca This feature works well, thank you for providing it.

One issue we’ve come across is that it seems we have no control over the filename. For example, the external service we use requires parameter based retrieval of a file using an id:

GET https://external-service/v1/file/[fileId]/content

When using this feature all files retrieved are saved in S3 with the name “content”. The file seems to be named according to the last part of the URL regardless of what the external API does. We have the actual filename for each file id, but we can’t figure out how to tell Bubble the name to use when saving the file.

So here are my questions:

  1. When using the File option, is there any way to specify the filename (using a non-private parameter)?
  2. If there is no way to specify the filename, is there any way to rename a file in a Bubble API Workflow (and if so can you share how we can do this)?
  3. If there is no way to specify the filename from a parameter, would you consider adding this feature? (It seems somewhat of an artificial limitation)

Thanks for reading and sorry to revive such an old thread.
(Also, I’m relatively new to Bubble so apologies if these are dumb questions)

2 Likes

Dear all, I believe I have a naive question but I can’t find an answer.

I have a third party service that creates my invoices (Adamo). I created an api (API1) that sends to Adamo the ingredients and they create my invoice. All good. I can retrieve API1 from a workflow and it works perfectly.

Now I want to get from Adamo a pdf and an Xml of the invoice and save them to Bubble. I created another api (API2) that retrieves the file. When I initialized it, it worked without errors and I could see the requested file in the file manager.

The problem I have is the following: in the workflows I can see and select API1 but I don’t see API2.
Any clue? Thanks in advance.

Did you set the API to action type and not data?

1 Like

I solved! I’m giving details here as other bubblers might find it useful.

The API1 can be recalled from a workflow. The API2 must instead be used in a different way. In order to save the file a thing must be edited and the relevant field must use “Get data from an external API” as per screenshot below.

P.S. API2 is set as “Uses as Data”

Exactly. DATA can be used in Get Data from API Connector in group fields… This also create a DB type of the API. Action can be called directly in the WF but will not create DB type.
In most case (but not all) a Call “GET” should be set as data type while POST PUT PATCH and DELETE should be set as action.

1 Like