Compare commits

..

2 Commits

Author SHA1 Message Date
ae0dc548ae Changed working directory on linux to /usr/share/tranga-api
Updated docker-compose to include settings-volume
2023-09-19 16:47:49 +02:00
051b85d08b Added contentType to response for images and logs 2023-09-19 16:43:08 +02:00
3 changed files with 21 additions and 3 deletions

View File

@ -522,7 +522,7 @@ public class Server : GlobalBase
response.AddHeader("Access-Control-Max-Age", "1728000"); response.AddHeader("Access-Control-Max-Age", "1728000");
response.AppendHeader("Access-Control-Allow-Origin", "*"); response.AppendHeader("Access-Control-Allow-Origin", "*");
if (content is not FileStream stream) if (content is not Stream)
{ {
response.ContentType = "application/json"; response.ContentType = "application/json";
try try
@ -537,8 +537,25 @@ public class Server : GlobalBase
Log(e.ToString()); Log(e.ToString());
} }
} }
else else if(content is FileStream stream)
{ {
string contentType = stream.Name.Split('.')[^1];
switch (contentType.ToLower())
{
case "gif":
response.ContentType = "image/gif";
break;
case "png":
response.ContentType = "image/png";
break;
case "jpg":
case "jpeg":
response.ContentType = "image/jpeg";
break;
case "log":
response.ContentType = "text/plain";
break;
}
stream.CopyTo(response.OutputStream); stream.CopyTo(response.OutputStream);
response.OutputStream.Close(); response.OutputStream.Close();
stream.Close(); stream.Close();

View File

@ -37,7 +37,7 @@ public class TrangaSettings
throw new ArgumentException("Download-location and working-directory paths can not be empty!"); throw new ArgumentException("Download-location and working-directory paths can not be empty!");
this.apiPortNumber = apiPortNumber ?? 6531; this.apiPortNumber = apiPortNumber ?? 6531;
this.downloadLocation = downloadLocation ?? (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/Manga" : Path.Join(Directory.GetCurrentDirectory(), "Downloads")); this.downloadLocation = downloadLocation ?? (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/Manga" : Path.Join(Directory.GetCurrentDirectory(), "Downloads"));
this.workingDirectory = workingDirectory ?? Path.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/var/lib" : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tranga-api"); this.workingDirectory = workingDirectory ?? Path.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/usr/share" : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tranga-api");
ExportSettings(); ExportSettings();
} }
else else

View File

@ -5,6 +5,7 @@ services:
container_name: tranga-api container_name: tranga-api
volumes: volumes:
- ./Manga:/Manga - ./Manga:/Manga
- ./settings:/usr/share/tranga-api
ports: ports:
- "6531:6531" - "6531:6531"
restart: unless-stopped restart: unless-stopped