node.js - nodejs actionhero download picture file trouble -


I am creating a simple image file upload / download server and I'm following it. In this section I am passing the xpath parameter which is the name of the file and it works fine for all text files, but I am getting 404 when trying the same for images.

  renderFile: function (API, connection, next) {// Any pre-rendering etc. connection.rawConnection.responseHttpCode = 200; Connection.sendFile (connection.params.xpath); Next (connection, wrong); }, Run: function (API, connection, next) {var self = this; If (connection.params.xpath == tap) {self.render404 (API, connection, next); } Else {var file = api.config.general.paths.public + '/' + connection.params.xpath console.log (file); Fs.exists (file, function (found) {if found} {self.renderFile (API, connection, next);} and {self.render404 (API, connection, next);}}); }}  

Do I have any settings or configs?

Everything looks right for me in the empty ActionHero project, I can use the action given below Am and http: // localhost: 8080 / api / file? Expectations like Xpath = logo / actionhero.png are required

  var fs = is required ('FS'); Export.action = {name: 'file', description: 'file', blockedConnectionTypes: [], outputExample: {}, matchExtensionMimeType: false, version: 1.0, toDocument: true, input: {required: [], optional: [ 'Xpath'],}, Render 404: Function (API, Connection, Next) {connection.rawConnection.responseHttpCode = 404; Connection.sendFile ('404.html'); Next (connection, wrong); }, Render file: function (API, connection, next) {connection.rawConnection.responseHttpCode = 200; Connection.sendFile (connection.params.xpath); Next (connection, wrong); }, Run: function (API, connection, next) {var self = this; If (connection.params.xpath == tap) {self.render404 (API, connection, next); } Other {fs.exists (file, function (found) {if found} {self.renderFile (api, connection, next);} else {self.render404 (api, connection, next);}}); }}};  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -