Я хочу загрузить фотографии с помощью React Native.Моя попытка API от Почтальона привела к положительному результату.Но React Native этого не сделал.
Функция React Native
uploadPhoto = async response => {
const data = new FormData();
data.append("image", {
uri: response.uri,
type: response.type,
name: response.fileName,
length:response.fileSize
});
const config={
headers:{
'Content-type':'multipart/form-data'
}
}
axios
.post('https://localhost:44337/api/values',JSON.stringify(data),config)
.then(response=>{
console.log(response);
})
.catch(error=>{console.log(error);})
};
Сторона ядра Asp.net
[HttpPost]
public IActionResult Post([FromForm]PhotoModel bookData)
{
//installation codes
return Ok();
}
Модель
public class PhotoModel
{
public IFormFile image { get; set; }
}
Результат: Ошибка сети