How to upload a image in javascript?

mc 3,701 Reputation points
2022-06-14T08:49:50.893+00:00

I am using abp vnext and there is a DTO in the api.

const fd = new FormData();  
            fd.append("file", document.getElementById('file1').files[0]);  
  
  
$.ajax({  
                url: '/api/app/merchant/image?Name=s',  
                type: "POST",  
                method: "POST",  
                data: fd,  
                contentType: false,  
      cache: false,  
                processData:false,  
                success: function (e) {  
  
                }  
            });  

there is a IRemoteStreamContent in the api.

but if I upload there is an error:

Deserialization of interface types is not surpported type Volo.Abp.IRemoteStreamContent.  

the interface is :

string FileName{get;}  
  
string ContentType{get;}  
  
Stream GetStream();  

how to fix it?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,207 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,931 Reputation points
    2022-06-14T19:49:19.02+00:00

    your javascript is doing a standard form file post. as for how the server supports this, see abp vendors documentation and ask the question there:

    a quick search on their site::

    https://community.abp.io/posts/file-uploaddownload-with-blob-storage-system-in-asp.net-core-abp-framework-d01cbe12

    0 comments No comments