diff --git a/AnalysisData/AnalysisData/Migrations/20240907083616_InitialCreate.Designer.cs b/AnalysisData/AnalysisData/Migrations/20240907084605_InitialCreate.Designer.cs
similarity index 99%
rename from AnalysisData/AnalysisData/Migrations/20240907083616_InitialCreate.Designer.cs
rename to AnalysisData/AnalysisData/Migrations/20240907084605_InitialCreate.Designer.cs
index ecbdca2..2f76033 100644
--- a/AnalysisData/AnalysisData/Migrations/20240907083616_InitialCreate.Designer.cs
+++ b/AnalysisData/AnalysisData/Migrations/20240907084605_InitialCreate.Designer.cs
@@ -12,7 +12,7 @@
namespace AnalysisData.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
- [Migration("20240907083616_InitialCreate")]
+ [Migration("20240907084605_InitialCreate")]
partial class InitialCreate
{
///
@@ -338,7 +338,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasData(
new
{
- Id = new Guid("12cb995a-4885-4ec3-9a3b-126b0ff89602"),
+ Id = new Guid("8ab41e25-44bb-4b43-aa2f-6f697edd425f"),
Email = "admin@gmail.com",
FirstName = "admin",
LastName = "admin",
diff --git a/AnalysisData/AnalysisData/Migrations/20240907083616_InitialCreate.cs b/AnalysisData/AnalysisData/Migrations/20240907084605_InitialCreate.cs
similarity index 99%
rename from AnalysisData/AnalysisData/Migrations/20240907083616_InitialCreate.cs
rename to AnalysisData/AnalysisData/Migrations/20240907084605_InitialCreate.cs
index 1fb4d45..2399dd3 100644
--- a/AnalysisData/AnalysisData/Migrations/20240907083616_InitialCreate.cs
+++ b/AnalysisData/AnalysisData/Migrations/20240907084605_InitialCreate.cs
@@ -279,7 +279,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Email", "FirstName", "ImageURL", "LastName", "Password", "PhoneNumber", "RoleId", "Username" },
- values: new object[] { new Guid("12cb995a-4885-4ec3-9a3b-126b0ff89602"), "admin@gmail.com", "admin", null, "admin", "jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=", "09131111111", 1, "admin" });
+ values: new object[] { new Guid("8ab41e25-44bb-4b43-aa2f-6f697edd425f"), "admin@gmail.com", "admin", null, "admin", "jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg=", "09131111111", 1, "admin" });
migrationBuilder.CreateIndex(
name: "IX_EntityEdges_EntityIDSource",
diff --git a/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs b/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs
index 08226d9..ca19ef2 100644
--- a/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs
+++ b/AnalysisData/AnalysisData/Migrations/ApplicationDbContextModelSnapshot.cs
@@ -335,7 +335,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasData(
new
{
- Id = new Guid("12cb995a-4885-4ec3-9a3b-126b0ff89602"),
+ Id = new Guid("8ab41e25-44bb-4b43-aa2f-6f697edd425f"),
Email = "admin@gmail.com",
FirstName = "admin",
LastName = "admin",
diff --git a/AnalysisData/AnalysisData/User/Controllers/UserController.cs b/AnalysisData/AnalysisData/User/Controllers/UserController.cs
index 92c9d0a..b8ce6e2 100644
--- a/AnalysisData/AnalysisData/User/Controllers/UserController.cs
+++ b/AnalysisData/AnalysisData/User/Controllers/UserController.cs
@@ -110,7 +110,8 @@ public async Task GetUserInformation()
FirstName = result.FirstName,
LastName = result.LastName,
PhoneNumber = result.PhoneNumber,
- Email = result.Email
+ Email = result.Email,
+ Image = result.ImageURL ?? "User do not have information yet !"
});
}
diff --git a/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs b/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs
index e448197..22c24c5 100644
--- a/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs
+++ b/AnalysisData/AnalysisData/User/Services/S3FileStorageService/S3FileStorageService.cs
@@ -12,12 +12,13 @@ public class S3FileStorageService : IS3FileStorageService
public S3FileStorageService(IConfiguration configuration)
{
+ var awsCredentials = new Amazon.Runtime.BasicAWSCredentials(configuration["AWS:AccessKey"], configuration["AWS:SecretKey"]);
+ var config = new AmazonS3Config
+ {
+ ServiceURL = configuration["AWS:ServiceURL"]
+ };
+ _s3Client = new AmazonS3Client(awsCredentials, config);
_bucketName = configuration["AWS:BucketName"];
- _s3Client = new AmazonS3Client(
- configuration["AWS:AccessKey"],
- configuration["AWS:SecretKey"],
- RegionEndpoint.GetBySystemName(configuration["AWS:Region"])
- );
}
public async Task UploadFileAsync(IFormFile file, string folderName)
@@ -32,8 +33,15 @@ public async Task UploadFileAsync(IFormFile file, string folderName)
ContentType = file.ContentType
};
- await _s3Client.PutObjectAsync(putRequest);
-
- return $"https://{_bucketName}.s3.amazonaws.com/{fileKey}";
+ var response = await _s3Client.PutObjectAsync(putRequest);
+ if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
+ {
+ var fileUrl = $"https://{_bucketName}.s3.{RegionEndpoint.USEast1.SystemName}.amazonaws.com/{fileKey}";
+ return fileUrl;
+ }
+ else
+ {
+ return "Could not upload .";
+ }
}
}
\ No newline at end of file
diff --git a/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs b/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs
index 434b97b..3593820 100644
--- a/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs
+++ b/AnalysisData/AnalysisData/User/Services/UserService/UploadImageService.cs
@@ -29,7 +29,7 @@ public async Task UploadImageAsync(ClaimsPrincipal claimsPrincipal, IFormF
string imageUrl = null;
if (file != null && file.Length > 0)
{
- imageUrl = await _s3FileStorageService.UploadFileAsync(file, "UserImages");
+ imageUrl = await _s3FileStorageService.UploadFileAsync(file, "usersProfile");
user.ImageURL = imageUrl;
}
user.ImageURL = imageUrl;
diff --git a/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs b/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs
index d673a57..c97e177 100644
--- a/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs
+++ b/AnalysisData/AnalysisData/User/UserDto/UserDto/GetUserInformationDto.cs
@@ -6,4 +6,6 @@ public class GetUserInformationDto
public string LastName { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
+
+ public string Image { get; set; }
}
\ No newline at end of file
diff --git a/AnalysisData/AnalysisData/appsettings.json b/AnalysisData/AnalysisData/appsettings.json
index 7f9f42d..3e04108 100644
--- a/AnalysisData/AnalysisData/appsettings.json
+++ b/AnalysisData/AnalysisData/appsettings.json
@@ -14,10 +14,11 @@
"UseS3": true
},
"AWS": {
- "Region": "us-west-2",
- "AccessKey": "956e557a5a204182972e38802cbb5eba",
- "SecretKey": "c4bbe0898e3746e08d33ddcde7e6d55e",
- "BucketName": "backend-abriment-com"
+ "Region": "us-east-1",
+ "AccessKey": "d022cd7a-8e0f-4e0d-b305-ae64116028c0",
+ "SecretKey": "19b8c45a60e797da10801b01c5a264804e3cafa07c77ec7bf4c40c09161523f2",
+ "BucketName": "stardata",
+ "ServiceURL": "https://s3.ir-thr-at1.arvanstorage.ir"
},
"EmailSettings": {
"SmtpServer": "smtp.gmail.com",
diff --git a/AnalysisData/TestProject/User/Controllers/UserControllerTests.cs b/AnalysisData/TestProject/User/Controllers/UserControllerTests.cs
index 866d9d8..12748f2 100644
--- a/AnalysisData/TestProject/User/Controllers/UserControllerTests.cs
+++ b/AnalysisData/TestProject/User/Controllers/UserControllerTests.cs
@@ -266,7 +266,9 @@ public async Task GetUserInformation_ShouldReturnOk_WhenUserExist()
FirstName = "test",
LastName = "test",
Email = "test@gmail.com",
- PhoneNumber = "09111111111"
+ PhoneNumber = "09111111111",
+ Image = "User do not have information yet !"
+
});
Assert.Equal(expectedResponseContent, responseContent);