GlideSysAttachment write of GlideSysAttachment getContent have different result

filipendris
Kilo Contributor

I am using restMessage to fetch image and attach it to records image type field in scoped app.

At start i just used rest saveResponseBodyAsAttachment method but that doesn't let me insert the attachment with just 'image' as it's name in case that instance has whitelist of allowed extensions filled and not blank.
So i wanted to save the attachment as 'image.jpeg' and then use

GlideSysAttachment.write(current, 'image', 'image/jpeg', GlideSysAttachment.getContent(gr)); // where gr is the original attachment

unfortunately these 2 attachments ends up to be completely different attachment.getContent gives me result as if I try to GlideSysAttachment.write restResponse.getBody() as the content.

I ran out of options how to do this beside of clearing the whitelist of extensions or allowing my scoped app write access to sys_attachment table and just using update and neither of these solutions are going to work for me.

Thanks for help.

5 REPLIES 5

treycarroll
Giga Guru

You can't call GlideSysAttachement.getContent() statically or you'll get:

 

InternalError: Java class "com.glide.ui.SysAttachment" has no public instance field or method named "getContent".

I

II realize that this thread is cold, but just posting as a PSA for anyone searching the community.