Attachment fields can be accessed in CloudCode with the following JavaScript API. This applies to fields of type="attachment", type="photo" and type="signature".
myobject.photo.present(); // false if not uploaded yet
myobject.photo.url(); // null if not uploaded yet
myobject.photo.processed('fullscreen').url();
await myobject.photo.toBuffer();
await myobject.photo.toBase64();
await myobject.mycsvfile.toText();
myobject.photo.toJSON(); // output state and urls in APIv4-compatible JSON.