Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Cannot serve files (png) #15

Closed
schmaluk opened this issue Feb 6, 2018 · 1 comment
Closed

Cannot serve files (png) #15

schmaluk opened this issue Feb 6, 2018 · 1 comment

Comments

@schmaluk
Copy link

schmaluk commented Feb 6, 2018

'use strict';

const SetupEndpoint = require('./setup/setup.js');

module.exports = SetupEndpoint({
    name: 'attachment',
    urls: [{
                   params: '/{file}',
                   requests: [{
                       sendFile: true,
                       mimeType: 'application/pdf',
                       //response: '/attachments/1.png',

                       response: '/attachments/test.pdf'
                   }]
               }
               ]
});

I get the error message:

2018-02-06/16:40:42.573, [response] http://localhost:8081: get /api/app/v6/attachment/test.pdf {} 500 (51ms)
2018-02-06/16:40:44.721, [log,connection,client,error] message: Parse Error, stack: Error: Parse Error
    at Error (native)
2018-02-06/16:40:44.728, [log,info] data: Received payload:null
Debug: internal, implementation, error 
    /project/attachments/test.pdf:1
(function (exports, require, module, __filename, __dirname) { %PDF-1.3
                                                              ^

SyntaxError: Unexpected token %
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at handler (/project/server/api/setup/setup.js:40:44)
2018-02-06/16:40:44.724, [response] http://localhost:8081: get /api/app/v6/attachment/test.pdf {} 500 (25ms)

@mischah
Copy link
Member

mischah commented Feb 6, 2018

https://github.com/micromata/http-fake-backend/blob/master/server/api/fileTypes.js should work on your machine too.

It seems, that you are not using the latest version of the fake backend.

Can you check the version number in the package.json?
It should be > than 4. See releases.

@mischah mischah closed this as completed Feb 6, 2018
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

2 participants