Added some folders.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
RakVhalate 2022-11-25 22:40:17 +10:00
parent 50a3c94af8
commit a4b72664fd
13 changed files with 53 additions and 50 deletions

View File

@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Data;
using System.Text.Json;
using NeDvachAPI.DBControllers;
namespace NeDvachAPI.Controllers
{

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.BufferControllers;
using System.Text.Json;
using System.Web.Http;
using HttpGetAttribute = Microsoft.AspNetCore.Mvc.HttpGetAttribute;

View File

@ -1,7 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualBasic;
using Microsoft.Win32.SafeHandles;
using System.IO;
using NeDvachAPI.DBControllers;
namespace NeDvachAPI.Controllers
@ -10,9 +8,7 @@ namespace NeDvachAPI.Controllers
[Route("[controller]")]
public class UploadPic : ControllerBase
{
///Local Buffer File Part
string filePath;
[HttpPost(Name = "UploadPicture")]
public async Task<JsonResult> ReceivePost([FromForm] IFormFile PostPicture)
@ -20,13 +16,12 @@ namespace NeDvachAPI.Controllers
var supportedTypes = new[] { "jpg", "png" };
string receivedFileName = PostPicture.FileName;
string fileExt = receivedFileName.Substring((receivedFileName.Length) - 3, 3);
//Console.WriteLine("Тип файла: " + fileExt);
if (supportedTypes.Contains(fileExt)) //file type check
{
///Local Buffer File Part
string filePath;
filePath = Directory.GetCurrentDirectory() + "\\Buffer\\" + receivedFileName;
Stream picBuffer = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
//Console.WriteLine("Закидываю файл в " + filePath);
PostPicture.CopyTo(picBuffer);
picBuffer.Close();
///MinIo part

View File

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.BufferControllers;
using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
using System.Text.Json;
namespace NeDvachAPI.Controllers

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using NeDvachAPI.BufferControllers;
using System.Text.Json;
using System.Web.Http;
using HttpGetAttribute = Microsoft.AspNetCore.Mvc.HttpGetAttribute;
@ -13,7 +14,7 @@ namespace NeDvachAPI.Controllers
[HttpGet(Name = "GetThreads")]
public string Get([FromUri] string board)
{
string postsJson = JsonSerializer.Serialize(APIThreadBuffer.GetOPPosts());
string postsJson = JsonSerializer.Serialize(APIThreadBuffer.GetThreadPreviews());
return postsJson;
}
}

View File

@ -1,4 +1,7 @@
namespace NeDvachAPI
using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
namespace NeDvachAPI.BufferControllers
{
public class APIThreadBuffer
{
@ -9,7 +12,7 @@
ThreadsPrewievs = OPPostsToWrite;
}
public static List<Post> GetOPPosts()
public static List<Post> GetThreadPreviews()
{
return ThreadsPrewievs;
}
@ -33,5 +36,6 @@
{
Threads[threadId - 1] = DBchat.PostsList("b", threadId);
}
}
}

View File

@ -1,4 +1,7 @@
namespace NeDvachAPI
using NeDvachAPI.DBControllers;
using NeDvachAPI.Models;
namespace NeDvachAPI.BufferControllers
{
public class BufferFill
{

View File

@ -1,7 +1,8 @@
using Npgsql;
using NeDvachAPI.Models;
using Npgsql;
using static System.Net.Mime.MediaTypeNames;
namespace NeDvachAPI
namespace NeDvachAPI.DBControllers
{
public class DBchat
{
@ -16,7 +17,7 @@ namespace NeDvachAPI
//int postCount = 0;
string received = "";
string connString =
String.Format(
string.Format(
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
AuthInfo.DB.Host,
AuthInfo.DB.User,
@ -87,7 +88,7 @@ namespace NeDvachAPI
//int postCount = 0;
string received = "";
string connString =
String.Format(
string.Format(
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
AuthInfo.DB.Host,
AuthInfo.DB.User,
@ -156,7 +157,7 @@ namespace NeDvachAPI
public static void DbUpdate(string id, string text)
{
string connString =
String.Format(
string.Format(
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
AuthInfo.DB.Host,
AuthInfo.DB.User,
@ -175,7 +176,7 @@ namespace NeDvachAPI
command.Parameters.AddWithValue("postText", text);
int nRows = command.ExecuteNonQuery();
Console.Out.WriteLine(String.Format("Number of rows updated={0}", nRows));
Console.Out.WriteLine(string.Format("Number of rows updated={0}", nRows));
}
}
@ -185,7 +186,7 @@ namespace NeDvachAPI
public static void SendPost(Post postToSend) //sending post to database
{
string connString =
String.Format(
string.Format(
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
AuthInfo.DB.Host,
AuthInfo.DB.User,
@ -232,7 +233,7 @@ namespace NeDvachAPI
public static void DeletePost(string idToDel) //удалялка
{
string connString =
String.Format(
string.Format(
"Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer",
AuthInfo.DB.Host,
AuthInfo.DB.User,
@ -253,7 +254,7 @@ namespace NeDvachAPI
command.Parameters.AddWithValue("ID", int.Parse(idToDel)); ;
int nRows = command.ExecuteNonQuery();
Console.Out.WriteLine(String.Format("Number of rows updated={0}", nRows));
Console.Out.WriteLine(string.Format("Number of rows updated={0}", nRows));
}
}

View File

@ -3,7 +3,7 @@ using Minio.DataModel;
using Minio;
using System.Security.Cryptography;
namespace NeDvachAPI
namespace NeDvachAPI.DBControllers
{
public class MinIOchat
{
@ -26,8 +26,8 @@ namespace NeDvachAPI
.WithContentType("image/png");
//.WithServerSideEncryption(ssec);
await DvachIo.PutObjectAsync(putObjectArgs);
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
File.Delete(fileroute);
return new JsonResult("http://static.vdk2ch.ru:15555/thread-pics/" + filename);

View File

@ -1,4 +1,4 @@
namespace NeDvachAPI
namespace NeDvachAPI.Models
{
public class Post
{

View File

@ -13,8 +13,4 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Buffer\" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,4 @@
using NeDvachAPI;
using NeDvachAPI.BufferControllers;
var builder = WebApplication.CreateBuilder(args);
@ -11,8 +11,8 @@ builder.Services.AddCors(setup =>
setup.AddDefaultPolicy(policyBuilder =>
{
policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("GET", "POST").WithHeaders("*");
//policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
//policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("GET", "POST").WithHeaders("*");
policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
});
});