diff options
author | crupest <crupest@outlook.com> | 2021-02-12 22:39:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-12 22:39:57 +0800 |
commit | c3d0a5f88de0fbdf6bc584548832017087ab1248 (patch) | |
tree | c1c992987263897fb1c091c5129c6d1f1e64073d /BackEnd/Timeline/Controllers/UserAvatarController.cs | |
parent | e232e31de839dc0c0de691c5856f29dcb92cf0fc (diff) | |
parent | 5849d34d9fcf1ccfb7fe5cc0842765129f7198b4 (diff) | |
download | timeline-c3d0a5f88de0fbdf6bc584548832017087ab1248.tar.gz timeline-c3d0a5f88de0fbdf6bc584548832017087ab1248.tar.bz2 timeline-c3d0a5f88de0fbdf6bc584548832017087ab1248.zip |
Merge pull request #267 from crupest/backend
春节大换血 Spring festival big change.
Diffstat (limited to 'BackEnd/Timeline/Controllers/UserAvatarController.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/UserAvatarController.cs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/BackEnd/Timeline/Controllers/UserAvatarController.cs b/BackEnd/Timeline/Controllers/UserAvatarController.cs index f3b7fff8..fa13f0f6 100644 --- a/BackEnd/Timeline/Controllers/UserAvatarController.cs +++ b/BackEnd/Timeline/Controllers/UserAvatarController.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks;
using Timeline.Filters;
using Timeline.Helpers;
+using Timeline.Helpers.Cache;
using Timeline.Models;
using Timeline.Models.Http;
using Timeline.Models.Validation;
@@ -63,11 +64,7 @@ namespace Timeline.Controllers return NotFound(ErrorResponse.UserCommon.NotExist());
}
- return await DataCacheHelper.GenerateActionResult(this, () => _service.GetAvatarETag(id), async () =>
- {
- var avatar = await _service.GetAvatar(id);
- return avatar.ToCacheableData();
- });
+ return await DataCacheHelper.GenerateActionResult(this, () => _service.GetAvatarDigest(id), () => _service.GetAvatar(id));
}
/// <summary>
@@ -105,16 +102,12 @@ namespace Timeline.Controllers try
{
- var etag = await _service.SetAvatar(id, new Avatar
- {
- Data = body.Data,
- Type = body.ContentType
- });
+ var digest = await _service.SetAvatar(id, body);
_logger.LogInformation(Log.Format(LogPutSuccess,
("Username", username), ("Mime Type", Request.ContentType)));
- Response.Headers.Append("ETag", new EntityTagHeaderValue($"\"{etag}\"").ToString());
+ Response.Headers.Append("ETag", $"\"{digest.ETag}\"");
return Ok();
}
@@ -166,7 +159,7 @@ namespace Timeline.Controllers return BadRequest(ErrorResponse.UserCommon.NotExist());
}
- await _service.SetAvatar(id, null);
+ await _service.DeleteAvatar(id);
return Ok();
}
}
|