After some help from @timkurvers (Thanks!) it turned out to be really easy. All that is needed is to pass over the file object as is. The annoying bit is that this was exactly what I tried in my first attempt. Only I must have done something wrong. For anyone wanting to do something similar; the code needed inside the coded component is this:
uploadByFile(file) {
return appfarm.actions.save_image({
blob: file
})
.then((...args) => {
const url = appfarm.data.new_image.get()
return {
success: 1,
file: {
url
}
}
})
}
file is the standard fileobject/blob from the browser. The action that saves the image looks like this:
And I’m passing back the Image (t).File Content as url:
Tim warned that this might break in future versions of Appfarm. I hope not.