Skip to content

Proper use of Container Model SDK #650

Description

@al041265

What type of issue are you creating?

  • Bug
  • Enhancement
  • Question

What version of this module are you using?

  • 2.0.10 (Stable)
  • 2.1.0-rc.n (2.1 Release Candidate n)
  • Other

Write other if any:

So I've been searching any clue on how to properly use the container model generated for the sdk, I'm using angular 8 to try to upload to my loopback 3 server;

` onFileSelect(event) {
if (event.target.files.length > 0) {
const file = event.target.files[0].name;
const formData = new FormData();
var reader = new FileReader();
formData.append('file ',event.target.files[0]);
// console.log(formData)
for (var [key, value] of formData.entries()) {
console.log(key, value);
}

    this.containerapi.upload('docs',formData,(response)=>
    {
     // console.log(response)
    }).subscribe((d)=>
    {
      console.log(d)
    },(error)=>{
      console.log(error)
    })

 

}

}`
this is my component.ts

`




                    <input #file id="file-input" type="file"  (change)="onFileSelect($event)"/>
                </div>`

this si the html part where the user selects the file and then its supposed to upload it.
I can understand the first parameter on the upload method, but what exactly I'm supposed to put on the request parameter?
I made it work testing the server endpoint with insomnia, as a multipart form and having a parameter called 'file', selecting the file, submitting and it uploaded it perfectly, but now trying with the sdk I cant figure out what Im doing wrong, any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions