nhost/hasura-storage

How to upload file using <input type=file />?

Nabinsharma123 opened this issue · 1 comments

i use <input type="file" /> to get image from the user
it return a file object.
so , i run

pic=inputFile[0]
nhost.storage.upload({ pic }).then((e) => {
            console.log(e);
        });

it returns an error

{fileMetadata: null, error: AxiosError}
error: AxiosErrorcode: "ERR_BAD_RESPONSE"config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}message: "Request failed with status code 500"name: "AxiosError"request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}response: {data: {…}, status: 500, statusText: '', headers: {…}, config: {…}, …}[[Prototype]]: ErrorfileMetadata: null[[Prototype]]: Object

same for text file also

i changed the name "pic" to "file" and it worked. :)