Filetransfer plugin Return error500 in Ionic

Asked

Viewed 8 times

0

I’m having problems with the fileTransfer, when I send an image it accepts sending normally, when sending in pf format it Reaches 99 Percent of sending and Returns error 500, a Detail that "taught" the server to understand pdf files. The server expects four Parameters: the file’s imputstream, code, Description and user email. As I said when sending images Works Perfectly

What I tried:

I reviewed the server log and when it is an image it accepts the upload when it is pdf it says it Did not receive the file (inputstream Parameter)

On Server:

   public String save(@FormDataParam("file") InputStream inputStream, @FormDataParam("description") String descCliente,
   @FormDataParam("code") String cod, @FormDataParam("email") String loginUsuario) throws Exception {

My get file method:

 getFile(){
    this.fileChooser.open().then((fileURL) =>{
      this.filePath.resolveNativePath(fileURL).then((data) => {
        this.file= data
      })
    })
  }

My upload method:

upload(payload){
    console.log(payload)
    
    var filePath = payload.imageURI;
    var filename = filePath.split("/").pop();
    var extencao = filename.split(".").pop();
    let server
    var options : FileUploadOptions;

    
    server = url
    options = {
      fileKey: "file",
      fileName: filename,
      chunkedMode: false,

      headers: {
        Connecection: "close"
      },
      params: {
        code: this.clienteSelecionado.codigo,
        description: payload.descricao,
        email: this.dados.usuario
      }
    }


    return this.fileTransfer.upload(filePath, server, options).then((data) =>{
      let retorno = JSON.parse(data.response)
      console.log(retorno)
      if (retorno.sucesso) {
        this.toastSucesso(retorno.mensagem)
      } else {
        this.toastSucesso(retorno.mensagem)
      }
      console.log()
    }, (error) => {
      console.log(error)
    });
  }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.