Bonsoir,
J'essai de faire un service web Rest upload image en asp.net et j'ai trouve des difficultés de le faire , si vous pouvez m'aider , le code ci-dessous est un service que j'ai crée mais sa n'a pas marche.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[HttpPost]
        [Route("api/post/ChmbreImages")]
         public FileContentResult PostImage([FromBody] CHAMBRE chambre)
        {
 
                //Depending on if you want the byte array or a memory stream, you can use the below. 
                var imageDataByteArray = Convert.FromBase64String(chambre.img);
 
                //When creating a stream, you need to reset the position, without it you will see that you always write files with a 0 byte length. 
                var imageDataStream = new MemoryStream(imageDataByteArray);
                imageDataStream.Position = 0;
 
                //Go and do something with the actual data.
                //_customerImageService.Upload([...])
 
                //For the purpose of the demo, we return a file so we can ensure it was uploaded correctly. 
                //But otherwise you can just return a 204 etc. 
                return File(imageDataByteArray, "image/png");
            }
 
 
        private FileContentResult File(byte[] imageDataByteArray, string p)
        {
            throw new NotImplementedException();
        }
Cordialement