Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Download document returning "File is not defined" #2

Open
stshelton opened this issue Mar 13, 2018 · 2 comments
Open

Download document returning "File is not defined" #2

stshelton opened this issue Mar 13, 2018 · 2 comments

Comments

@stshelton
Copy link

Currently using firebase's node js cloud servers and want to download images of documents to my own storage to later show user. Yet when I try to download the image from onfido js-client I get an error saying "File is not defined". Any idea why? I am new to node.js and backend should I be parsing the return object to a certain type of file ??

@GiuliaDi
Copy link

Hi! could you please contact the Onfido support team at [email protected]?
Could you also please give us more details on how you are downloading the documents? (i.e. the request that you sent to the Onfido API)
Best regards

@Aldekein
Copy link

Aldekein commented Nov 22, 2019

The error is still there. Didn't no one try to download files for more than a year?
Here's an example code:

const Onfido = require('onfido');
var fs = require('fs');
const secret = fs.readFileSync('config/onfido_token.txt', 'utf8');
const defaultClient = Onfido.ApiClient.instance;
const tokenAuth = defaultClient.authentications['Token'];
tokenAuth.apiKey = 'token='+secret;
tokenAuth.apiKeyPrefix = 'Token';
const api = new Onfido.DefaultApi();
const document = await api.downloadDocument('INSERT applicantId HERE', 'INSERT documentId HERE');

It will give an error:

ReferenceError: File is not defined
    at exports.downloadDocumentWithHttpInfo (/private/var/www/onfido-backuper/node_modules/onfido/src/api/DefaultApi.js:406:24)
    at exports.downloadDocument (/private/var/www/onfido-backuper/node_modules/onfido/src/api/DefaultApi.js:422:19)
...

In DefaultApi.js you can see:

      var authNames = ['Token'];
      var contentTypes = [];
      var accepts = ['*/*', 'application/json'];
      var returnType = File;     // <------------ there an unknown variable is referenced

      return this.apiClient.callApi(
        '/applicants/{applicant_id}/documents/{document_id}/download', 'GET',
        pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType
      );

When using var returnType = 'Blob'; it works as it should.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants