Aurelia js fie upload to server

前端 未结 1 1293
孤街浪徒
孤街浪徒 2021-01-29 05:53

Hi am new to aurelia js , i need to upload file to server,am using autrelia js, materializecss and httpClient.fetch for api call. I dont\'know how to send file to server.

1条回答
  •  走了就别回头了
    2021-01-29 06:55

    If it's a file and you are trying to upload a particular media type, the header 'Content-Type': 'application/x-www-form-urlencoded' does not seem right to me. Have a look at the appropriate media type here:

    http://www.iana.org/assignments/media-types/media-types.xhtml

    Also, you serialize data to JSON, if your data is binary you will need to change that to a byte array.

    You might find some useful info here:

    http://www.petermorlion.com/file-upload-with-aurelia/

    Also you set a token both in your URL and your header, I'd recommend to set it in the header only.

    0 讨论(0)
提交回复
热议问题