Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the new return arg type "file" #34

Closed
bajtos opened this issue Apr 7, 2016 · 4 comments
Closed

Support the new return arg type "file" #34

bajtos opened this issue Apr 7, 2016 · 4 comments

Comments

@bajtos
Copy link
Member

bajtos commented Apr 7, 2016

In strongloop/strong-remoting#284, we added support for new return type "file":

MyModel.download = function(cb) {
  // this can be for example http.request()
  getTheStreamBody(function(err, stream) {
    if (err) return cb(err);
    // stream can be any of: string, buffer, ReadableStream (e.g. http.IncomingMessage)
    cb(null, stream, 'application/octet-stream');
  });
}

MyModel.remoteMethod('download', {
  isStatic: true,
  returns: [
    { arg: 'body', type: 'file', root: true },
    { arg: 'Content-Type', type: 'string', http: { target: 'header' } },
  ],
});

Now we need to extend swagger-spec generator to support his new file and map it to swagger type "file".

Nice to have: support return arguments mapped as http.target:header too.

@stale
Copy link

stale bot commented Aug 23, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Sep 6, 2017
@stale
Copy link

stale bot commented Sep 6, 2017

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@eisverticker
Copy link

eisverticker commented Jan 10, 2018

the file loopback type is still not documented and the loopback-cli does not support that type either
see loopback type documentation

@bajtos
Copy link
Member Author

bajtos commented Jan 12, 2018

A status update/summary for anybody discovering this issue (cc @eisverticker @bschrammIBM). As I understand it, our support for "file" type is partial only.

At the side of remote method output ("returns" arguments):

At the side of remote method inputs ("accepts" arguments):

Actionable items for volunteers wanting to help us to make "file" support happen:

  • Modify swagger spec generator to recognize "file" return types, as described at the top of this GH issue (this should be fairly easy).
  • Improve strong-remoting to support "file" uploads (Allow remote methods to accept uploaded files loopback#3266). This is a pretty advanced task requiring quite a bit of knowledge about how HTTP requests work in Node.js and how are file uploads represented in HTTP messages. The code in loopback-component-storage's upload function is a good source of inspiration.

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

No branches or pull requests

2 participants