# Uncaught (in promise) TypeError: Object prototype may only be an Object or null: undefined

**URL:** <https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139>\
**Category:** General Discussion\
**Created:** [March 24, 2021, 11:16am UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139 "2021-03-24T11:16:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DmitriyDmytruk](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/dmitriydmytruk/32/2394_2.png) [@DmitriyDmytruk](https://forum.solidproject.org/u/DmitriyDmytruk)\
**Post date:** [March 24, 2021, 11:16am UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139/1 "2021-03-24T11:16:49Z")

</div>

On the front-end I use React.  
I want to upload a file to a solid container.  
I took this code as an example.

> <https://github.com/jeff-zucker/solid-file-client/blob/master/docs/node-upload.md>

The difference is that I use `solid-auth-fetcher` for authorization. The code looks like this

```
const auth = require('solid-auth-cli')
const fc = new SolidFileClient(auth)
await fc.copyFile("file:///home/m0nte-cr1st0/fasf.jpg", "https://dimadmytruk23.inrupt.net/fasf.jpg" )

```

The user is already logged in at the time of the file upload.

However, I am getting the following error.

```
polyfills.js:139 Uncaught (in promise) TypeError: Object prototype may only be an Object or null: undefined
    at Function.setPrototypeOf (<anonymous>)
    at polyfills.js:139
    at patch (polyfills.js:141)
    at patch (graceful-fs.js:104)
    at Object.<anonymous> (graceful-fs.js:96)
    at Object../node_modules/graceful-fs/graceful-fs.js (graceful-fs.js:373)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at Object../node_modules/solid-rest/node_modules/fs-extra/lib/fs/index.js (index.js:5)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at Object../node_modules/solid-rest/node_modules/fs-extra/lib/index.js (index.js:5)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at Object.<anonymous> (file.js:4)
    at Object../node_modules/solid-rest/src/file.js (file.js:214)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at setRestHandlers (index.js:10)
    at Object.fetch (index.js:33)
    at SolidFileClient.fetch (SolidApi.js:140)
    at SolidFileClient.get (SolidApi.js:155)
    at SolidFileClient.copyFile (SolidApi.js:515)
    at Transcription.tsx:53

```

The file is there. The path is correct.

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [March 24, 2021, 11:37am UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139/2 "2021-03-24T11:37:18Z")

</div>

Hi Dmitry, as its author, @jeffz will know most about solid-file-client, but I’m quite sure that you’re unable to refer to local files (e.g. `file://...`) from scripts running in the browser, which I’m assuming is the case for you judging by your use of React?

---

<div class="post-metadata">

**Author:** ![DmitriyDmytruk](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/dmitriydmytruk/32/2394_2.png) [@DmitriyDmytruk](https://forum.solidproject.org/u/DmitriyDmytruk)\
**Post date:** [March 24, 2021, 11:41am UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139/4 "2021-03-24T11:41:19Z")

</div>

Hi @Vincent . Thnx for answer.

I also have a base64 blob of this file.

---

<div class="post-metadata">

**Author:** ![jeffz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeffz/32/600_2.png) [@jeffz](https://forum.solidproject.org/u/jeffz)\
**Post date:** [March 24, 2021, 2:51pm UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139/5 "2021-03-24T14:51:29Z")

</div>

TL;DR If you want to upload file using a browser app, you need to do it using one of the browser app auth packages and a file-upload input field. Here is a working example of [uploading from local file to remote pod from a browser with solid-file-client](https://jeff-zucker.github.io/solid-file-client/docs/examples/).

Longer answer : Solid-File-Client is browser agnostic - it can run either inside a browser or on the command line but takes different auth libraries for the two usages. In the browser you may use any of solid-client-authn-browser, solid-auth-fetcher, or solid-auth-client. Outside the browser your auth should be solid-node-client (or now deprecated solid-auth-cli) or, if you don’t need to access file:/// URLs solid-client-authn-node.

Out of all those auth libraries, only solid-node-client and solid-auth-cli can work with file:// URLs and those auth packages only work outside a browser. I have a library that works with the browser’s Native File API but that only works on files in a browser sandbox that can’t be accessed outside the browser. AFAIK, there is no way to directly access a file:// URL from a browser other than possibly browser extensions.

---

<div class="post-metadata">

**Author:** ![DmitriyDmytruk](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/dmitriydmytruk/32/2394_2.png) [@DmitriyDmytruk](https://forum.solidproject.org/u/DmitriyDmytruk)\
**Post date:** [March 25, 2021, 1:48pm UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139/6 "2021-03-25T13:48:34Z")

</div>

Thank @jeffz . You have a really great library for working with files.

As I said, I use `solid-auth-fetcher` for authorization.  
I managed to merge these two libraries.

```auto
const auth = require('solid-auth-fetcher')
const fc = new SolidFileClient(auth)

```

As I said above, I have a `base64 string` of an image. I successfully load it using the `createFile` method.

But I have problems with displaying data. I read them from a folder using the `readFolder` method. The data comes in the form of links. They are correct, there are images. But when I try to insert them into my website page in the `img` tag, I get an `401 error` ( **user already logged in** ).

`z6Cvanl6Pk.jpeg:1 GET https://dimadmytruk23.inrupt.net/screenshots/z6Cvanl6Pk.jpeg 401 (Unauthenticated)`

---

<div class="post-metadata">

**Author:** ![jeffz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeffz/32/600_2.png) [@jeffz](https://forum.solidproject.org/u/jeffz)\
**Post date:** [March 25, 2021, 3:54pm UTC](https://forum.solidproject.org/t/uncaught-in-promise-typeerror-object-prototype-may-only-be-an-object-or-null-undefined/4139/7 "2021-03-25T15:54:46Z")

</div>

A 401 error on a GET means that the user is unauthenticated to read the resource. If you want the resource to be readable by anyone, you need to set sharing on the resource to either Write or Append+Read - if the resource is only set to Append (for example in the /inbox/), that does not provide Read access.
