connection string and some fix for get exam image
This commit is contained in:
parent
44b4341fe7
commit
38a0adced8
|
|
@ -6,6 +6,7 @@ using System;
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Specialized;
|
||||
using System.Net;
|
||||
|
||||
namespace OnlineAssessment.Helpers
|
||||
{
|
||||
|
|
@ -97,12 +98,30 @@ namespace OnlineAssessment.Helpers
|
|||
|
||||
public async Task<Stream> GetFile(string key)
|
||||
{
|
||||
string file = key + ".png";
|
||||
GetObjectResponse response = await _amazonS3.GetObjectAsync(_settings.AWSS3.BucketName, file);
|
||||
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
|
||||
return response.ResponseStream;
|
||||
else
|
||||
|
||||
try
|
||||
{
|
||||
string file = key.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ? key : key + ".png";
|
||||
string filename_print = _settings.AWSS3.BucketName + file;
|
||||
|
||||
var response = await _amazonS3.GetObjectAsync(_settings.AWSS3.BucketName, file);
|
||||
|
||||
if (response.HttpStatusCode == HttpStatusCode.OK)
|
||||
return response.ResponseStream;
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (AmazonS3Exception ex)
|
||||
{
|
||||
Console.WriteLine($"AWS S3 Error: {ex.Message} ({ex.ErrorCode})");
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"General Error: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteFile(string key)
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@ namespace OnlineAssessment
|
|||
{
|
||||
|
||||
string connString1 = @"Server=94.249.213.139;Database=OA_STAGING;User Id=sa;Password=Odiware@1234!;TrustServerCertificate=True;MultipleActiveResultSets=true";
|
||||
string connection1 = AesEncryptionHelper.Encrypt(connString1);
|
||||
//string connection1 = AesEncryptionHelper.Encrypt(connString1);
|
||||
|
||||
|
||||
string connString = configuration.GetConnectionString("DefaultConnectionString");
|
||||
string connection = AesEncryptionHelper.Decrypt(connString);
|
||||
//string connString = configuration.GetConnectionString("DefaultConnectionString");
|
||||
//string connection = AesEncryptionHelper.Decrypt(connString);
|
||||
string connection = connString1;
|
||||
|
||||
//============================================
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue