android 数据回传代码,安卓向.net core api传输图片,执行保存到数据库命令后返回400错误代码,用postman测试没有问题安卓程序不行...
安卓向.net core api傳輸圖片,執行保存到數據庫命令后返回400錯誤代碼,用postman測試沒有問題安卓程序不行,其他api沒有問題,在執行保存到數據庫命令之前也沒有問題。希望各位大佬可以幫我解決一下問題,.net core代碼如下:
[HttpPost]
[Route("UploadImage")]
public async Task UploadImageAsync(IFormFile tx, [FromForm]string userId)
{
try
{
Account account = await _context.Account.FirstAsync(a => a.UserId == int.Parse(userId));
MemoryStream memory = new MemoryStream();
tx.CopyTo(memory);
account.UserPhoto = memory.ToArray();
account.UserPhotoType = tx.ContentType;
// return Ok(account.UserPhotoType+account.UserPhoto);
//return Ok(tx.FileName + " " + userId + " " + account.UserId);
_context.Update(account);
await _context.SaveChangesAsync();
return Ok("123456789");
}
catch (Exception e)
{
return BadRequest(new { state = "Error", msg = e.Message ,trace=e.StackTrace});
}
}
總結
以上是生活随笔為你收集整理的android 数据回传代码,安卓向.net core api传输图片,执行保存到数据库命令后返回400错误代码,用postman测试没有问题安卓程序不行...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端获取后端传来的session_用ja
- 下一篇: Pytho学习笔记:电子邮件1