@c8y/client 1018.377.0 → 1018.379.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4338,7 +4338,8 @@
4338
4338
  }
4339
4339
  const fullUrl = this.getUrl(url, init);
4340
4340
  const options = this.getFetchOptions(init);
4341
- return fetchFn(fullUrl, options);
4341
+ const optionsWithAdjustedBody = this.adjustOptionsForFormData(options);
4342
+ return fetchFn(fullUrl, optionsWithAdjustedBody);
4342
4343
  });
4343
4344
  }
4344
4345
  getUrl(url = '', options) {
@@ -4387,6 +4388,10 @@
4387
4388
  throw Error('Your environment does not support relative URLs. Please provide a base URL.');
4388
4389
  }
4389
4390
  }
4391
+ adjustOptionsForFormData(options) {
4392
+ const newOptions = Object.assign(options, { body: options.body });
4393
+ return newOptions;
4394
+ }
4390
4395
  }
4391
4396
 
4392
4397
  var error = function (message) {
@@ -5192,13 +5197,9 @@
5192
5197
  }
5193
5198
  body.append('file', file, fileName);
5194
5199
  body.append('object', JSON.stringify(managedObject));
5195
- let bodyHeaders;
5196
- if (typeof body.getHeaders === 'function') {
5197
- bodyHeaders = body.getHeaders();
5198
- }
5199
- const headers = Object.assign({
5200
+ const headers = {
5200
5201
  accept: 'application/json'
5201
- }, bodyHeaders);
5202
+ };
5202
5203
  const res = yield this.fetch(url, { method, body, headers });
5203
5204
  const data = yield res.json();
5204
5205
  return { res, data };
@@ -5277,7 +5278,14 @@
5277
5278
  }
5278
5279
  }
5279
5280
  xhr.upload.addEventListener('progress', onProgress);
5280
- xhr.send(body);
5281
+ let xhrBody;
5282
+ if (typeof body.getBuffer === 'function') {
5283
+ xhrBody = body.getBuffer();
5284
+ }
5285
+ else {
5286
+ xhrBody = body;
5287
+ }
5288
+ xhr.send(xhrBody);
5281
5289
  return xhr;
5282
5290
  }
5283
5291
  getXMLHttpResponse(xhr) {
@@ -7921,7 +7929,14 @@
7921
7929
  }
7922
7930
  }
7923
7931
  xhr.upload.addEventListener('progress', onProgress);
7924
- xhr.send(body);
7932
+ let xhrBody;
7933
+ if (typeof body.getBuffer === 'function') {
7934
+ xhrBody = body.getBuffer();
7935
+ }
7936
+ else {
7937
+ xhrBody = body;
7938
+ }
7939
+ xhr.send(xhrBody);
7925
7940
  return xhr;
7926
7941
  }
7927
7942
  getXMLHttpResponse(xhr) {
@@ -7965,13 +7980,9 @@
7965
7980
  const body = new browser();
7966
7981
  const bufferOrStream = pluginFile instanceof ArrayBuffer ? Buffer.from(pluginFile) : pluginFile;
7967
7982
  body.append('file', bufferOrStream);
7968
- let bodyHeaders;
7969
- if (typeof body.getHeaders === 'function') {
7970
- bodyHeaders = body.getHeaders();
7971
- }
7972
- const headers = Object.assign({
7983
+ const headers = {
7973
7984
  accept: 'application/json'
7974
- }, bodyHeaders);
7985
+ };
7975
7986
  const res = yield this.fetch(url, { method, body, headers });
7976
7987
  const data = yield res.json();
7977
7988
  return { res, data };
@@ -7996,13 +8007,9 @@
7996
8007
  const bufferOrStream = file.contents instanceof ArrayBuffer ? Buffer.from(file.contents) : file.contents;
7997
8008
  body.append(file.path, bufferOrStream);
7998
8009
  });
7999
- let bodyHeaders;
8000
- if (typeof body.getHeaders === 'function') {
8001
- bodyHeaders = body.getHeaders();
8002
- }
8003
- const headers = Object.assign({
8010
+ const headers = {
8004
8011
  accept: 'application/json'
8005
- }, bodyHeaders);
8012
+ };
8006
8013
  const res = yield this.fetch(url, { method, body, headers });
8007
8014
  const data = yield res.json();
8008
8015
  return { res, data };
@@ -9843,13 +9850,9 @@
9843
9850
  }
9844
9851
  }
9845
9852
  body.append('file', csv, fileName);
9846
- let bodyHeaders;
9847
- if (typeof body.getHeaders === 'function') {
9848
- bodyHeaders = body.getHeaders();
9849
- }
9850
- const headers = Object.assign({
9853
+ const headers = {
9851
9854
  accept: 'application/json'
9852
- }, bodyHeaders);
9855
+ };
9853
9856
  const res = yield this.client.fetch(url, { method, body, headers });
9854
9857
  const data = yield res.json();
9855
9858
  return { res, data };