diff --git a/plugins/arcgis/service/src/FeatureQuerier.ts b/plugins/arcgis/service/src/FeatureQuerier.ts index 395f085d0..d00a35da1 100644 --- a/plugins/arcgis/service/src/FeatureQuerier.ts +++ b/plugins/arcgis/service/src/FeatureQuerier.ts @@ -67,9 +67,8 @@ export class FeatureQuerier { params: { f: 'json' } }); - this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse.toString) - const result = queryResponse as QueryObjectResult - response(result); + this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2)) + response(queryResponse as QueryObjectResult) } /** @@ -91,9 +90,8 @@ export class FeatureQuerier { params: { f: 'json' } }); - this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse) - const result = queryResponse as QueryObjectResult - response(result) + this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2)) + response(queryResponse as QueryObjectResult) } /** @@ -108,13 +106,19 @@ export class FeatureQuerier { queryUrl.searchParams.set('outFields', this.outFields([field])); queryUrl.searchParams.set('returnGeometry', 'false'); this._console.info('ArcGIS query: ' + queryUrl) - - const queryResponse = await request(queryUrl.toString(), { - authentication: this._identityManager - }); - this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse) - const result = queryResponse as QueryObjectResult - response(result) + + try { + const queryResponse = await request(queryUrl.toString(), { + authentication: this._identityManager, + params: { f: 'json' } + + }); + + this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2)) + response(queryResponse as QueryObjectResult) + } catch (err) { + console.error("could not query", err) + } } /** diff --git a/plugins/arcgis/service/src/ObservationsSender.ts b/plugins/arcgis/service/src/ObservationsSender.ts index f57cdc2ee..7e33de95d 100644 --- a/plugins/arcgis/service/src/ObservationsSender.ts +++ b/plugins/arcgis/service/src/ObservationsSender.ts @@ -270,20 +270,22 @@ export class ObservationsSender { * @param objectId The arc object id of the observation. */ private async sendAttachment(attachment: ArcAttachment, objectId: number) { - const file = path.join(this._attachmentDirectory, attachment.contentLocator!) - - const fileName = this.attachmentFileName(attachment) - this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file) - - const readStream = await fs.openAsBlob(file) - const test = new File([readStream], fileName) - - addAttachment({ - url: this._url, - authentication: this._identityManager, - featureId: objectId, - attachment: test - }).catch((error) => this._console.error(error)); + if (attachment.contentLocator) { + const file = path.join(this._attachmentDirectory, attachment.contentLocator!) + + const fileName = this.attachmentFileName(attachment) + this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file) + + const readStream = await fs.openAsBlob(file) + const attachmentFile = new File([readStream], fileName) + + addAttachment({ + url: this._url, + authentication: this._identityManager, + featureId: objectId, + attachment: attachmentFile + }).catch((error) => this._console.error(error)); + } } /** @@ -293,21 +295,23 @@ export class ObservationsSender { * @param attachmentId The observation arc attachment id. */ private async updateAttachment(attachment: ArcAttachment, objectId: number, attachmentId: number) { - const file = path.join(this._attachmentDirectory, attachment.contentLocator!) - - const fileName = this.attachmentFileName(attachment) - this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file) - - const readStream = await fs.openAsBlob(file) - const test = new File([readStream], fileName) - - updateAttachment({ - url: this._url, - authentication: this._identityManager, - featureId: objectId, - attachmentId, - attachment: test - }).catch((error) => this._console.error(error)); + if (attachment.contentLocator) { + const file = path.join(this._attachmentDirectory, attachment.contentLocator!) + + const fileName = this.attachmentFileName(attachment) + this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file) + + const readStream = await fs.openAsBlob(file) + const attachmentFile = new File([readStream], fileName) + + updateAttachment({ + url: this._url, + authentication: this._identityManager, + featureId: objectId, + attachmentId, + attachment: attachmentFile + }).catch((error) => this._console.error(error)); + } } /**