attachTo parameter in context.upload - Custom plugins

Can anyone explain to me how this is supposed to work please? This is the documentation:
uploadContent: function(fileName: String, contents: Base64 String, callback: function(err, url), [attachTo])
attachTo: optional parameter to attach the file to. It has to be a thing in Bubble

I’m not sure how to use the attachTo parameter. It seems like it allows you to upload files directly to a thing in bubble but to what field? Given there is no documentation on how to specify the field on the “thing” then I’m thinking my guess might be a bit off but I can’t think of anything else it would be used for.

Anyone have any ideas?
Thanks in advance

You can provide a Bubble item id. This item eil have the file attached to it an provacy rules will be applied according to this thing settings. It’s not added to any field, just attached to a thing. This is the same thing as if you use make this file private in file uploader.

1 Like

I see. Ok thanks for your help. Is there then a way to get access to these “attached” files via a dynamic expression?

When you use this function, you get back the file url in Bubble storage. You can use this file url in a dynamic expression or save it to a field

Yes, I knew that part, but you get the file url back regardless of whether you use the attachTo function or not. I was asking in the bubble design tab, is there a way to access the file that was attached to the bubble “thing”

You access the fill attached to a thing the same way as you access a file not attached to a thing.

Consider this:
having the url into a field in a thing DOESN’T make it “attach” to a thing. So file are not secure even if the field is secure, the file url could be shared to anyone else and the file will not be private.

attachTo is only related to file privacy

Makes sense. Thanks for the clarification.

1 Like