After fiddling a long time with the ādetect dataā-function to get this to work I tried it with just adding the data format myself.
Just put the Key āfileā and Type āimageā by hand and it magically works.
Wondering if anyone has had luck with this since. I believe Iāve got my JSON object formatted properly, being passed to my endpoint, but the result I get in the bubble db is a blank image.
Look correctly at the first part of your video (Emmanual Post).
The file information are store in a āfileā parameter (you can call it whatever you want)
this give
Thanks @Jici, Iāve tried with that exact format as well (with the file JSON object, then filename and contents stored in that object) but no luck. Just retested and Iām still getting this as the record in the DB.
@Jici thanks for the help here ā hereās the initialize call (1st image) and the api workflow detect data result for the endpoint Iām trying to set up
I forget. But if you use autodetect, the file is split in two part. You can save contents to field (just set image or field) but you need to save the name in another field.
I test it with data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5NWvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29uc/P9cmJu9MTDImIN+/r7+/vz8/P8VNQGNugV8AAF9fX8swMNgTAFlDOICAgPNSUnNWSMQ5MBAQEJE3QPIGAM9AQMqGcG9vb6MhJsEdGM8vLx8fH98AANIWAMuQeL8fABkTEPPQ0OM5OSYdGFl5jo+Pj/+pqcsTE78wMFNGQLYmID4dGPvd3UBAQJmTkP+8vH9QUK+vr8ZWSHpzcJMmILdwcLOGcHRQUHxwcK9PT9DQ0O/v70w5MLypoG8wKOuwsP/g4P/Q0IcwKEswKMl8aJ9fX2xjdOtGRs/Pz+Dg4GImIP8gIH0sKEAwKKmTiKZ8aB/f39Wsl+LFt8dgUE9PT5x5aHBwcP+AgP+WltdgYMyZfyywz78AAAAAAAD///8AAP9mZv///w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oLX6Kqx+yXqqBANsgCtit4FWQAEkrNbpq7HSOmtwag5w57GrmlJBASEU18ADjUYb3ADTinIttsgSB1oJFfA63bduimuqKB1keqwUhoCSK374wbujvOSu4QG6UvxBRydcpKsav++Ca6G8A6Pr1x2kVMyHwsVxUALDq/krnrhPSOzXG1lUTIoffqGR7Goi2MAxbv6O2kEG56I7CSlRsEFKFVyovDJoIRTg7sugNRDGqCJzJgcKE0ywc0ELm6KBCCJo8DIPFeCWNGcyqNFE06ToAfV0HBRgxsvLThHn1oddQMrXj5DyAQgjEHSAJMWZwS3HPxT/QMbabI/iBCliMLEJKX2EEkomBAUCxRi42VDADxyTYDVogV+wSChqmKxEKCDAYFDFj4OmwbY7bDGdBhtrnTQYOigeChUmc1K3QTnAUfEgGFgAWt88hKA6aCRIXhxnQ1yg3BCayK44EWdkUQcBByEQChFXfCB776aQsG0BIlQgQgE8qO26X1h8cEUep8ngRBnOy74E9QgRgEAC8SvOfQkh7FDBDmS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg+kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw==
without any problem.
Now if you want to save it to s3, I recommend to manually encode the api data. It should save to s3 this way with the filename.
@Jici or others - how does one save the base64 as a file? My original assumption was that the file contents were going to be saved to S3 and referencing that as the source of the the image I create.
When creating the Image record (like first image) Iām still getting it as a Base64 filetype (second image)
Dear blueback09, could you please advice how to do this : 10. setup your API to recognize the āfileā parameter as a file and the āexampleā parameter as text
API workflow in question is the āS3 saveā workflow, which Iām hoping to pass a file (base64 image) and a name (text) via a Post endpoint Iāve set up. Iād then like to have Bubble create a new image record, saving it with a URL that I can link to, as it would for images Iād upload using image uploader element. Use case for storing Base64 image as an image file w/ URL is for a text editor Iām using making in a CMS. Users will upload an image to the text editor interface Iām using and Iād prefer to not have the long Base64 image data in the HTML markup.
Whenever I save, the data in the Image field is stored as Base64 (so it teases me, rendering as an image) but if you look at the image source itās Base64 like second link below.
Hi @eric3, I tweaked your project, and it works now. Check it to see the details. The tma1.jpg image is what I posted through your endpoint.
I think the issue was that the āInitialize / Detect request dataā feature should NOT be used. Instead, manually define the parameters as shown. The file parameter can be called whatever you want (āuploaded_imageā in this case), as @Jici noted. Additional āfield valuesā for the āthingā being created can be defined at the JSON root.
Of course I was looking through to wrong end of the telescope as usualā¦
Not having the image in base64 in the first place is a lot easier than trying to convert it to an image file in Bubble ! (which will probably need a server side plugin and a little bit of code).
One more quick note (which @NigelGās reference to base64 encoding prompted)ā¦
The base64-encoded image should NOT contain the ādata:mimetype;base64ā prefix. Thatās needed only in the context of a data URL - i.e. only if you intend to store the image data itself directly in the DB so that the image data is part of the URL and thus served with the page source and rendered āinlineā.
That could make sense in some situations for relatively small images, but itās generally not the best way to go for most images.
Dear eric3. thanks for your help. Could you please comment how do your fill in point 2. filed Body {JSON object,ā¦ā¦ā¦ā¦ it looks like you put data directly in bubble(base64 coded image)ā¦.but what to wright there if we want to send to endpoint different files?
Thanks Jici, but may be it should be like this:
{
ātitleā: <āSorry, Daveā>,
āuploaded_imageā: {
āfilenameā: <ātma1.jpgā>,
ācontentsā: <"/9j/4AAQSkZJRg [ā¦]">
},
āuploaded_image2ā: {
āfilenameā: <ātma2.jpgā>,
ācontentsā: <"/9j/4AAQSkZJRg [ā¦]">
}
} I what file name to be variable