This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ActionLogger] | |
public class HomeController : Controller | |
{ | |
public IActionResult Index() | |
{ | |
return View(); | |
} | |
public IActionResult Privacy() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void OnActionExecuted(ActionExecutedContext context) | |
{ | |
System.Net.IPAddress ipAddress = context.HttpContext.Connection.RemoteIpAddress; | |
string controllerName = ((ControllerActionDescriptor)context.ActionDescriptor).ControllerName; | |
string actionName = ((ControllerActionDescriptor)context.ActionDescriptor).ActionName; | |
if (context.Exception == null) | |
{ | |
Log | |
.ForContext("IPAddress", ipAddress) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Startup(IConfiguration configuration, IHostingEnvironment environment) | |
{ | |
Configuration = configuration; | |
Environment.SetEnvironmentVariable("AWS_ACCESS_KEY_ID", configuration.GetSection("AWS:AccessKey").Value); | |
Environment.SetEnvironmentVariable("AWS_SECRET_ACCESS_KEY", configuration.GetSection("AWS:SecretKey").Value); | |
Environment.SetEnvironmentVariable("AWS_REGION", configuration.GetSection("AWS:Region").Value); | |
Log.Logger = new LoggerConfiguration() | |
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(configuration.GetSection("AWS:ElasticUrl").Value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Configuration; | |
using Minio; | |
using Minio.DataModel; | |
using Minio.Exceptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<FileResult> DownloadFile(string fileName) | |
{ | |
//MinIO Bağlantısı | |
string endPoint = _config["Minio:Endpoint"]; | |
string accessKey = _config["Minio:Accesskey"]; | |
string secretKey = _config["Minio:SecretKey"]; | |
MinioClient minioClient = new MinioClient(endPoint, accessKey, secretKey); | |
string bucketName = "medium"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string GetContentType(string fileName) | |
{ | |
if (fileName.Contains(".jpg")) | |
{ | |
return "image/jpg"; | |
} | |
else if(fileName.Contains(".jpeg")){ | |
return "image/jpeg"; | |
}else if (fileName.Contains(".png")) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public async Task<IActionResult> Index(IFormFile file) | |
{ | |
FileViewModel viewModel = new FileViewModel(); | |
//Yüklenen dosyanın MemoryStream nesnesini oluşturalım | |
MemoryStream stream = new MemoryStream(); | |
file.CopyTo(stream); | |
stream.Position = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
public IActionResult Index() | |
{ | |
return View(); | |
} | |
[HttpPost] | |
public IActionResult Index(IFormFile file) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model FileViewModel; | |
<div class="container" style="margin-top:100px"> | |
<br/> | |
@{ | |
if(Model != null) | |
{ | |
<a href="@Url.Action("DownloadFile", new { fileName = Model.FileName })">@Model.FileName indir</a> | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build(); | |
//Disable send button until connection is established | |
document.getElementById("sendButton").disabled = true; | |
connection.on("ReceiveMessage", function (user, message) { | |
var msg = message.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); | |
if (user == $("#userInput").val()) { |