@@ -270,20 +270,22 @@ export class ObservationsSender {
270270 * @param objectId The arc object id of the observation.
271271 */
272272 private async sendAttachment ( attachment : ArcAttachment , objectId : number ) {
273- const file = path . join ( this . _attachmentDirectory , attachment . contentLocator ! )
274-
275- const fileName = this . attachmentFileName ( attachment )
276- this . _console . info ( 'ArcGIS ' + request + ' file ' + fileName + ' from ' + file )
277-
278- const readStream = await fs . openAsBlob ( file )
279- const test = new File ( [ readStream ] , fileName )
280-
281- addAttachment ( {
282- url : this . _url ,
283- authentication : this . _identityManager ,
284- featureId : objectId ,
285- attachment : test
286- } ) . catch ( ( error ) => this . _console . error ( error ) ) ;
273+ if ( attachment . contentLocator ) {
274+ const file = path . join ( this . _attachmentDirectory , attachment . contentLocator ! )
275+
276+ const fileName = this . attachmentFileName ( attachment )
277+ this . _console . info ( 'ArcGIS ' + request + ' file ' + fileName + ' from ' + file )
278+
279+ const readStream = await fs . openAsBlob ( file )
280+ const attachmentFile = new File ( [ readStream ] , fileName )
281+
282+ addAttachment ( {
283+ url : this . _url ,
284+ authentication : this . _identityManager ,
285+ featureId : objectId ,
286+ attachment : attachmentFile
287+ } ) . catch ( ( error ) => this . _console . error ( error ) ) ;
288+ }
287289 }
288290
289291 /**
@@ -293,21 +295,23 @@ export class ObservationsSender {
293295 * @param attachmentId The observation arc attachment id.
294296 */
295297 private async updateAttachment ( attachment : ArcAttachment , objectId : number , attachmentId : number ) {
296- const file = path . join ( this . _attachmentDirectory , attachment . contentLocator ! )
297-
298- const fileName = this . attachmentFileName ( attachment )
299- this . _console . info ( 'ArcGIS ' + request + ' file ' + fileName + ' from ' + file )
300-
301- const readStream = await fs . openAsBlob ( file )
302- const test = new File ( [ readStream ] , fileName )
303-
304- updateAttachment ( {
305- url : this . _url ,
306- authentication : this . _identityManager ,
307- featureId : objectId ,
308- attachmentId,
309- attachment : test
310- } ) . catch ( ( error ) => this . _console . error ( error ) ) ;
298+ if ( attachment . contentLocator ) {
299+ const file = path . join ( this . _attachmentDirectory , attachment . contentLocator ! )
300+
301+ const fileName = this . attachmentFileName ( attachment )
302+ this . _console . info ( 'ArcGIS ' + request + ' file ' + fileName + ' from ' + file )
303+
304+ const readStream = await fs . openAsBlob ( file )
305+ const attachmentFile = new File ( [ readStream ] , fileName )
306+
307+ updateAttachment ( {
308+ url : this . _url ,
309+ authentication : this . _identityManager ,
310+ featureId : objectId ,
311+ attachmentId,
312+ attachment : attachmentFile
313+ } ) . catch ( ( error ) => this . _console . error ( error ) ) ;
314+ }
311315 }
312316
313317 /**
0 commit comments