Closed devInterests closed 7 years ago
Hey @devInterests sorry about the delayed response.
The accepts.type
must a LoopBack type.
I am going to close this issue for now but please feel free to carry on the conversation in here or re-open if you believe this is still an issue.
Hello,
@richardpringle I was aware of the list. It seems I misunderstood this answer: Uploading images
- We allow remote method parameters to be typed as ‘File’. If one of the parameters is typed as ‘File’, only ‘multipart/form-data’ content type is supported.
It sounds to me like the File-Type is supported.
@devInterests, the idea is that type "File" will eventually be supported.
Does your fileUpload
method work at all? If not, I suggest either using loopback-component-storage, or go take a look at the code so you can implement your own.
The storage-service
code is where you'll find the remote method and its metadata. The upload
method actually call handler.upload
which can be found in the storage-handler
file.
I think it would be easiest to just add loopback-component-storage as a datasource service without exposing the container to the public REST API.
Keep the conversation going in here and we'll get your method working the way you want it to!
@richardpringle thanks.
My file upload works just fine, when I am using object
as a Argument-Type.
The problem here is that the Swagger-UI treats it as a object.
When I am using File
as a Argument-Type, Swagger-UI treats it as a file upload.
It is showing Browser-Button to select a File, and a Upload-Button.
But then loopback get the error.
I would like to have the right definition with the File-Type, because then Swagger showing the Rest-Interface correctly (which is part of the rest documentation) and also I can test with Swagger directly.
Interesting,
I am going to re-open this issue as a feature request then.
@devInterests, would you be interested in submitting a PR to add support of type File?
@devInterests, what version of strong-remoting do you have? I just came across this issue that should support type File: https://github.com/strongloop/loopback/issues/2063#issuecomment-189204577
Edit: Sorry, that's actually only supported for returns
Closing as a duplicate of https://github.com/strongloop/loopback/issues/2554
Ooops, this is not a duplicate of strongloop/loopback#2554, reopening.
@devInterests if I understand your comments correctly, then you would like strong-remoting to support {arg: 'file', type: 'file', http: { source: 'body' }, required: true}
, is that correct?
Closing as a duplicate of https://github.com/strongloop/loopback/issues/3266
If you have a remote method with a parameter that's type: 'file' you receive following error:
"Error: Invalid value for argument 'file' of type 'file': [object Object]. Received type was converted to object.
As far as I understood the error is in function convertToBasicRemotingType in shared-method.js:
The type
file
is supported as a separate type. The problem is that the arg is coming as typeobject
. My fix at the moment is to useobject
as arg type or to use a older version where the file type is not supported and becomes default typeobject
. But i would like to use the correct type:file
.My interface definition:
Perhaps I am doing something wrong?