Skip to content

Commit

Permalink
简化图片下载API
Browse files Browse the repository at this point in the history
  • Loading branch information
Redns committed Mar 27, 2022
1 parent a64a824 commit 74e1cbb
Show file tree
Hide file tree
Showing 26 changed files with 20 additions and 5 deletions.
Binary file not shown.
Binary file modified .vs/ImageBed/v17/.suo
Binary file not shown.
7 changes: 4 additions & 3 deletions Controllers/ImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using ImageBed.Data.Entity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using System.Net;
using System.Net.Http.Headers;

namespace ImageBed.Controllers
{
Expand Down Expand Up @@ -63,9 +65,8 @@ public IActionResult Get(string filename)
{
imagePath = $"{AppSettings.Get("Data:Resources:Images:Path")}/imageNotFound.jpg";
}
var imageStream = System.IO.File.OpenRead(imagePath);
var memi = new FileExtensionContentTypeProvider().Mappings[$".{UnitNameGenerator.GetFileExtension(filename)}" ?? "image"];
return File(imageStream, memi, Path.GetFileName(filename));

return File(System.IO.File.ReadAllBytes(imagePath), $"image/{UnitNameGenerator.GetFileExtension(filename)}");
}


Expand Down
Binary file removed Data/Resources/Images/1648247071564.jpg
Binary file not shown.
File renamed without changes
Binary file added Data/Resources/Images/1648421260890.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Resources/Images/1648421607233.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Resources/Images/1648421762956.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Resources/Images/1648422348458.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Resources/Images/1648422509441.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Resources/Images/1648422630167.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Properties/PublishProfiles/FolderProfile.pubxml.user
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<_PublishTargetUrl>D:\Project\ImageBed\bin\Release\net6.0\publish\</_PublishTargetUrl>
<History>True|2022-03-27T12:15:43.7802058Z;True|2022-03-25T22:24:45.6590264+08:00;True|2022-03-25T22:16:56.3121054+08:00;True|2022-03-25T22:14:58.3048004+08:00;True|2022-03-25T21:57:59.6895276+08:00;True|2022-03-25T21:47:39.9886632+08:00;True|2022-03-06T20:53:13.2926466+08:00;True|2022-03-06T19:10:23.2974300+08:00;True|2022-03-06T19:07:45.3352516+08:00;True|2022-03-06T18:48:30.1587937+08:00;True|2022-03-06T18:47:48.4978613+08:00;True|2022-03-06T17:48:35.3765104+08:00;True|2022-03-06T17:45:56.4462389+08:00;True|2022-03-06T17:42:13.9819644+08:00;True|2022-03-06T17:30:03.2610584+08:00;True|2022-03-06T17:24:55.2112848+08:00;</History>
<History>True|2022-03-27T15:10:44.5752490Z;True|2022-03-27T22:40:30.9391564+08:00;True|2022-03-27T20:15:43.7802058+08:00;True|2022-03-25T22:24:45.6590264+08:00;True|2022-03-25T22:16:56.3121054+08:00;True|2022-03-25T22:14:58.3048004+08:00;True|2022-03-25T21:57:59.6895276+08:00;True|2022-03-25T21:47:39.9886632+08:00;True|2022-03-06T20:53:13.2926466+08:00;True|2022-03-06T19:10:23.2974300+08:00;True|2022-03-06T19:07:45.3352516+08:00;True|2022-03-06T18:48:30.1587937+08:00;True|2022-03-06T18:47:48.4978613+08:00;True|2022-03-06T17:48:35.3765104+08:00;True|2022-03-06T17:45:56.4462389+08:00;True|2022-03-06T17:42:13.9819644+08:00;True|2022-03-06T17:30:03.2610584+08:00;True|2022-03-06T17:24:55.2112848+08:00;</History>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ImageBed": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:12121",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
Binary file modified bin/Debug/net6.0/ImageBed.dll
Binary file not shown.
Binary file modified bin/Debug/net6.0/ImageBed.pdb
Binary file not shown.
Binary file modified bin/Release/net6.0/ImageBed.dll
Binary file not shown.
Binary file modified bin/Release/net6.0/ImageBed.pdb
Binary file not shown.
Binary file modified bin/Release/net6.0/publish/ImageBed.dll
Binary file not shown.
Binary file modified bin/Release/net6.0/publish/ImageBed.pdb
Binary file not shown.
Binary file modified obj/Debug/net6.0/ImageBed.dll
Binary file not shown.
Binary file modified obj/Debug/net6.0/ImageBed.pdb
Binary file not shown.
Binary file modified obj/Release/net6.0/ImageBed.dll
Binary file not shown.
Binary file modified obj/Release/net6.0/ImageBed.pdb
Binary file not shown.
Binary file modified obj/Release/net6.0/PubTmp/Out/ImageBed.dll
Binary file not shown.
Binary file modified obj/Release/net6.0/PubTmp/Out/ImageBed.pdb
Binary file not shown.
14 changes: 14 additions & 0 deletions obj/staticwebassets.pack.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,17 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

0 comments on commit 74e1cbb

Please sign in to comment.