How do i structure my JSON for Uploading Multiple Images/Files?

How do I structure my JSON for Multiple Images/Files?

So I am trying to upload multiple images to a field of type List of Images.

{
filename: String
contents: Base64-encoded binary data
private: Boolean
attach_to: String
}

The server accepts when I call [’{
filename: String
contents: Base64-encoded binary data
private: Boolean
attach_to: String
}’]
If I add quotes for the JSON key’s it shows error.

The problem is that the data is stored as a string, not as an Image.

1 Like

@emmanuel @NigelG Please help. I searched the forums couldn’t find anything for multiple image json pattern.

Hey @ajayrwarrier did you figure this out?

I am trying to do something like this:

  "Attachments": [
    {
      "Name": "fileurl.png",
      "Content": "dGVzdCBjb250ZW50",
      "ContentType": "image/png"
    }
  ]

I am using the Postmark API. This is what Postmark says:

The Content field stores the binary data for the file, which must be transmitted as a base64-encoded string.

I can convert the image(s) to a base64 string, which turns out to be several thousand characters. But how do I get “binary data” out of a Base64 string? I have absolutely no idea.

Any help would be greatly appreciated.
@NigelG I know you have worked with Postmark (In fact I am using Postmark based on you advocacy on the forum :wink: )
Do you have any idea how this can be done in Bubble?

I found a work around. Not sure if its “better” but at least it seems fairly lightweight.
So please don’t exhaust yourselves, on helping me with this issue.

@ajayrwarrier hope you figured your issue out.

I am just going to use an HTML image element in a template (for now) And change the source URL dynamically.

However if someone does have some insight on this process, would be great to hear. Adding image source in template might not be the best solution.

Pull the Postmark cURL in using the API connector.

Put the bit in square brackets into a single parameter. Get it working with test data first.

On the thing with the repeating data … have a text field.

image

Populate with real data.

image

The glue it all back together with commas when sending to Postmark.

image

It seems logn-winded, but actually once you have the “email formatted” line on each thing, you can just drop it in whenever you need it.

image

2 Likes

@ajayrwarrier Did you manage to solve your problem?

I’m doing a POST with my JSON like this
[{
filename: String
contents: Base64-encoded binary data
private: Boolean
attach_to: String
},
{
filename: String
contents: Base64-encoded binary data
private: Boolean
attach_to: String
}]

But the following return is displayed:

 "statusCode": 400,
 "body": {
     "status": "INVALID_DATA",
     "message": "Invalid data for key files: Expected a file url as a string, but got an object (original data:

When I remove the brackets and send only one file it works fine.