# How to receive response, that is blob object, with kintone.proxy?

**URL:** <https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260>\
**Category:** General\
**Created:** [March 3, 2022, 3:15am UTC](https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260 "2022-03-03T03:15:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [March 3, 2022, 3:15am UTC](https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260/1 "2022-03-03T03:15:30Z")

</div>

I downloaded icon on a domain of kintone with kintone.proxy. The response is in text format. I want to receive a blob object. Which way can i do to receive desire result?

Thanks

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [March 3, 2022, 10:15pm UTC](https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260/2 "2022-03-03T22:15:39Z")

</div>

Hello Tan,

As Chris mentioned in the other post,&nbsp; [https://developer.kintone.io/hc/en-us/community/posts/4549066182041](https://developer.kintone.io/hc/en-us/community/posts/4549066182041)

could you try and see by writing,

```
const data = { format: "RAW", value: new Blob([arrayBuffer]) };

```

resolves the issue you are having?  
Hopefully, this helps.

Sean

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [March 4, 2022, 2:29am UTC](https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260/3 "2022-03-04T02:29:12Z")

</div>

Thanks, Sean,

Maybe my description is not clear. My problem: I am standing at domain A of Kintone, downloading an icon file (png) from domain B of Kintone using `kintone.proxy`. Then, I upload the file's content to the current domain (domain A), and then I attempt to set the file key to general settings. Kintone informs me that the file is not in PNG, JPEG, etc. format. What can I do to resolve this problem?

### Download File Code:

```javascript
get_file_dev(filekey, api_url='k/v1/file.json') {
  let url = this.dev_domain + api_url + `?fileKey=${filekey}`;
  return kintone.proxy(url, 'GET', header_dev, {}).then(resp => {
    return resp[0];
  }, error => {
    throw `${error.message} get file key ${filekey} fail`;
  });
}

```

### Upload File Code: (data = resp[0])

```javascript
upload_file_product(data, object_data, api_url='k/v1/file.json') {
  return new Promise(function (resolve, reject) {
    let blob = new Blob([data], {type: object_data['contentType']});
    let formData = new FormData();
    formData.append(' __REQUEST_TOKEN__', kintone.getRequestToken());
    formData.append('file', blob, object_data['name']);
    let url = kintone.api.url(`/${api_url}`);
    let xhr = new XMLHttpRequest();
    xhr.open('POST', url);
    xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    xhr.onload = function() {
      if (xhr.status === 200) {
        // success
        resolve(JSON.parse(xhr.responseText)['fileKey']);
      } else {
        reject(JSON.parse(xhr.responseText));
        throw `${JSON.parse(xhr.responseText)} upload file ${object_data['name']} fail`;
      }
    };
    xhr.send(formData);
  });
}

```

Thank you for your support.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [March 5, 2022, 5:47pm UTC](https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260/4 "2022-03-05T17:47:21Z")

</div>

Hi Tan,

Thank you for your reply.

In the kintone.proxy function, only strings are supported as the response body returned by the proxy destination.  
In other words, binary data such as images cannot be retrieved.

However, if you use the kintone.proxy.upload function, which uploads files to an external location, can execute file upload API.

[https://kintone.dev/en/docs/kintone/js-api/other/kintone-proxy-upload/](https://kintone.dev/en/docs/kintone/js-api/other/kintone-proxy-upload/)

[https://kintone.dev/en/docs/kintone/rest-api/files/upload-file/](https://kintone.dev/en/docs/kintone/rest-api/files/upload-file/)

After downloading the file using XMLHttpRequest on domain B, execute the file upload API on domain B using the kintone.proxy.upload function on domain A.

Hopefully, this helps.

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [March 7, 2022, 3:00am UTC](https://forum.kintone.dev/t/how-to-receive-response-that-is-blob-object-with-kintone-proxy/260/5 "2022-03-07T03:00:26Z")

</div>

Hi Sean

Thank you for your support,

I must stand at domain A to download icon at domain B. So I can’t use XMLHttpRequest to download icon at domain B.

Thank you so much. You are kind
