some scretches about file upload
This commit is contained in:
parent
7737725327
commit
b9d7f50cc9
19
Controllers/PictureUpload.cs
Normal file
19
Controllers/PictureUpload.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace NeDvachAPI.Controllers
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("[controller]")]
|
||||||
|
public class UploadPic : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost(Name = "UploadPicture")]
|
||||||
|
public JsonResult ReceivePost([FromForm] IFormFile PostPicture)
|
||||||
|
{
|
||||||
|
Console.Write("Принята картинка ");
|
||||||
|
Console.WriteLine(PostPicture.FileName);
|
||||||
|
return new JsonResult(PostPicture.FileName + " получен!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@ namespace NeDvachAPI
|
|||||||
using ( var command = new NpgsqlCommand(@"
|
using ( var command = new NpgsqlCommand(@"
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(
|
(
|
||||||
SELECT post_id, post, post_timestamp
|
SELECT post_id, post, post_timestamp, post_pic
|
||||||
FROM dvach
|
FROM dvach
|
||||||
ORDER BY post_id DESC
|
ORDER BY post_id DESC
|
||||||
) subquery
|
) subquery
|
||||||
@ -67,7 +67,8 @@ namespace NeDvachAPI
|
|||||||
{
|
{
|
||||||
Id = reader.GetInt32(0),
|
Id = reader.GetInt32(0),
|
||||||
Text = reader.GetString(1),
|
Text = reader.GetString(1),
|
||||||
Timestamp = reader.GetString(2)
|
Timestamp = reader.GetString(2),
|
||||||
|
ImgURL = (string)reader.GetString(3)
|
||||||
};
|
};
|
||||||
posts.Add(receivedPost);
|
posts.Add(receivedPost);
|
||||||
//posts[postCount] = receivedPost;
|
//posts[postCount] = receivedPost;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
|
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
7
Post.cs
7
Post.cs
@ -7,12 +7,7 @@ namespace NeDvachAPI
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public class ReceivedValues
|
public string ImgURL { get; set; }
|
||||||
{
|
|
||||||
public string height { get; set; }
|
|
||||||
|
|
||||||
public string altitude { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,8 +12,8 @@ builder.Services.AddCors(setup =>
|
|||||||
setup.AddDefaultPolicy(policyBuilder =>
|
setup.AddDefaultPolicy(policyBuilder =>
|
||||||
{
|
{
|
||||||
|
|
||||||
policyBuilder.WithOrigins("http://www.vdk2ch.ru: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("*");
|
policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user