[New Feature] File option on API Connector plugin

Hey @marca, can I ask a somewhat weird question? If one is creating an API to send back a FILE (in addition to other things) in response to a POST request … is there a way to do that with JSON? The question is: WHAT is Bubble looking for that makes it interpret a JSON object coming back as a file?

(I get that the feature you’ve enabled here is a generic GET type operation, but my question is related.)

I’ve built several little microservices that shoot stuff back to Bubble in response to POSTs. However, I have a need for one that shoots back a block of text (works fine), a FILE representation of that text (with filename, etc.), and some other data. I just cannot figure out how to get Bubble to interpret the FILE part as a file.

The difficulty being: I’m building my microservices in Webtask.io, which is Node. Node doesn’t have the same File() constructor as plain-old-Javascript. But the “file” I’m making is literally just a text file (my microservice composes its text and it’s completely stored in memory).

What would I send back to Bubble to make the Bubble API connector see it as a File? I’ve tried all sorts of things, like just sending back the bits base64 encoded, sending a JSON that looks like the one described in https://bubble.io/reference#API.sending_data under “Files and Images”, etc.

It would be EXTREMELY handy if there were some thing I could construct (without having to resort to file streams or whatnot) that would tell Bubble, “Hey, this JSON represents a file. Here’s its data, suggested filename, and MIME type. It’s all there – just save this to s3 and return me that URL.”

I guess I’m just missing something… But it’s weird that the API connector “initialize call” feature allows one to tell Bubble “interpret this part of the JSON as being type ‘file’”, but nothing seems to be accepted…

Any help you might be able to offer?

Best regards,
Keith