diff --git a/database/mistox.sql b/database/mistox.sql
index 3b5175a..da44b17 100755
--- a/database/mistox.sql
+++ b/database/mistox.sql
@@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS `Company` (
`Email` varchar(255) DEFAULT NULL,
`EmailVerified` boolean DEFAULT 0,
`WebsiteURL` varchar(255) DEFAULT NULL,
- `LogoURL` varchar(2048) DEFAULT NULL,
+ `Logo` mediumblob DEFAULT NULL,
`Phone` varchar(20) DEFAULT NULL,
`PostalCode` varchar(20) NOT NULL,
`Country` char(2) NOT NULL,
diff --git a/src/Client/src/app/models/Company.ts b/src/Client/src/app/models/Company.ts
index 99a6eb7..80a1e65 100644
--- a/src/Client/src/app/models/Company.ts
+++ b/src/Client/src/app/models/Company.ts
@@ -4,7 +4,7 @@ export class Company {
public email: string = "";
public emailVerified: boolean = false;
public websiteURL: string = "";
- public logoURL: string = "";
+ public logo: string = "";
public phone: string = "";
public postalCode: string = "";
public country: string = ""; // 2 Letter Country Code
diff --git a/src/Client/src/app/pages/main/company/company.component.html b/src/Client/src/app/pages/main/company/company.component.html
index 54ca043..3f3a63d 100644
--- a/src/Client/src/app/pages/main/company/company.component.html
+++ b/src/Client/src/app/pages/main/company/company.component.html
@@ -8,7 +8,7 @@
city: {{ newListing.city }}
diff --git a/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts b/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts
index 25bde87..11be3da 100644
--- a/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts
+++ b/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts
@@ -20,6 +20,7 @@ export class CompanyConnectComponent {
public newListing: Company = new Company();
public ErrorMsg: string = "";
+ MaxFileMB: number = 3;
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Company - Connect | BoredCareers");
@@ -54,6 +55,30 @@ export class CompanyConnectComponent {
}, 500);
}
+ selectedFile: File | null = null;
+ onFileSelected(event: Event){
+ const fileInput = event.target as HTMLInputElement;
+ this.selectedFile = null;
+
+ if (!fileInput.files?.length){
+ return;
+ }
+
+ let file = fileInput.files[0];
+ if (file.size > this.MaxFileMB * 1024 * 1024){
+ this.ErrorMsg = "File exceeds max file size of 16MB";
+ return;
+ }
+ // No issues add file to the list
+ this.selectedFile = file;
+
+ const reader = new FileReader();
+ reader.onload= () => {
+ this.newListing.logo = reader.result as string;
+ }
+ reader.readAsDataURL(file);
+ }
+
nextStep(){
this.currentStep += 1;
this.updateUI(0);
@@ -85,7 +110,7 @@ export class CompanyConnectComponent {
return;
}
- if (this.isNullOrEmpty(company.logoURL)){
+ if (this.isNullOrEmpty(company.logo)){
this.focusFrame(2, 0);
return;
}
diff --git a/src/Client/src/app/pages/main/jobs/viewer/jobviewer.component.html b/src/Client/src/app/pages/main/jobs/viewer/jobviewer.component.html
index a49aeb4..23243a9 100644
--- a/src/Client/src/app/pages/main/jobs/viewer/jobviewer.component.html
+++ b/src/Client/src/app/pages/main/jobs/viewer/jobviewer.component.html
@@ -5,7 +5,7 @@
{{ jobsCompany.email }}
{{ jobsCompany.websiteURL }}
- {{ jobsCompany.logoURL }}
+ {{ jobsCompany.logo }}
{{ jobsCompany.phone }}
{{ jobsCompany.city }}
diff --git a/src/Server/Entities/Company.cs b/src/Server/Entities/Company.cs
index cd8fbae..1d78a4b 100644
--- a/src/Server/Entities/Company.cs
+++ b/src/Server/Entities/Company.cs
@@ -6,7 +6,7 @@ namespace BoredCareers.Entities {
public string Email { get; set; } = "";
public bool EmailVerified { get; set; } = false;
public string WebsiteURL { get; set; } = "";
- public string LogoURL { get; set; } = "";
+ public string Logo { get; set; } = "";
public string Phone { get; set; } = "";
public string PostalCode { get; set; } = "";
public string Country { get; set; } = ""; // 2 Letter Country Code
diff --git a/src/Server/Services/DatabaseService/Company.cs b/src/Server/Services/DatabaseService/Company.cs
index a4c64a3..504e481 100644
--- a/src/Server/Services/DatabaseService/Company.cs
+++ b/src/Server/Services/DatabaseService/Company.cs
@@ -2,6 +2,7 @@ using BoredCareers.Entities;
using MySql.Data.MySqlClient;
using System.Data;
using System.Data.Common;
+using System.Text;
namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService {
@@ -27,7 +28,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL");
- string _logourl = reader.GetString( "LogoURL" );
+ string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" );
@@ -41,7 +42,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email,
EmailVerified = _emailVerified,
WebsiteURL = _websiteurl,
- LogoURL = _logourl,
+ Logo = _logo,
Phone = _phone,
PostalCode = _postalcode,
Country = _country,
@@ -61,15 +62,15 @@ namespace BoredCareers.Services.DatabaseService {
string command = @"
INSERT INTO Company
- (ID,Name,Email,EmailVerified,WebsiteURL,LogoURL,Phone,PostalCode,Country,StateOrRegion,City,Description)
+ (ID,Name,Email,EmailVerified,WebsiteURL,Logo,Phone,PostalCode,Country,StateOrRegion,City,Description)
VALUES
- (@ID,@Name,@Email,@EmailVerified,@WebsiteURL,@LogoURL,@Phone,@PostalCode,@Country,@StateOrRegion,@City,@Description)
+ (@ID,@Name,@Email,@EmailVerified,@WebsiteURL,@Logo,@Phone,@PostalCode,@Country,@StateOrRegion,@City,@Description)
ON DUPLICATE KEY UPDATE
Name = @Name,
Email = @Email,
EmailVerified = @EmailVerified,
WebsiteURL = @WebsiteURL,
- LogoURL = @LogoURL,
+ Logo = @Logo,
Phone = @Phone,
PostalCode = @PostalCode,
Country = @Country,
@@ -86,7 +87,7 @@ namespace BoredCareers.Services.DatabaseService {
cmd.Parameters.AddWithValue("@Email", company.Email);
cmd.Parameters.AddWithValue("@EmailVerified", company.EmailVerified);
cmd.Parameters.AddWithValue("@WebsiteURL", company.WebsiteURL);
- cmd.Parameters.AddWithValue("@LogoURL", company.LogoURL);
+ cmd.Parameters.AddWithValue("@Logo", Encoding.UTF8.GetBytes(company.Logo));
cmd.Parameters.AddWithValue("@Phone", company.Phone);
cmd.Parameters.AddWithValue("@PostalCode", company.PostalCode);
cmd.Parameters.AddWithValue("@Country", company.Country);
diff --git a/src/Server/Services/DatabaseService/Employee.cs b/src/Server/Services/DatabaseService/Employee.cs
index 07e3989..143a5b0 100644
--- a/src/Server/Services/DatabaseService/Employee.cs
+++ b/src/Server/Services/DatabaseService/Employee.cs
@@ -2,6 +2,7 @@ using BoredCareers.Entities;
using MySql.Data.MySqlClient;
using System.Data;
using System.Data.Common;
+using System.Text;
namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService {
@@ -30,7 +31,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL");
- string _logourl = reader.GetString( "LogoURL" );
+ string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" );
@@ -47,7 +48,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email,
EmailVerified = _emailVerified,
WebsiteURL = _websiteurl,
- LogoURL = _logourl,
+ Logo = _logo,
Phone = _phone,
PostalCode = _postalcode,
Country = _country,
@@ -86,7 +87,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL");
- string _logourl = reader.GetString( "LogoURL" );
+ string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" );
@@ -103,7 +104,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email,
EmailVerified = _emailVerified,
WebsiteURL = _websiteurl,
- LogoURL = _logourl,
+ Logo = _logo,
Phone = _phone,
PostalCode = _postalcode,
Country = _country,
@@ -142,7 +143,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL");
- string _logourl = reader.GetString( "LogoURL" );
+ string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" );
@@ -159,7 +160,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email,
EmailVerified = _emailVerified,
WebsiteURL = _websiteurl,
- LogoURL = _logourl,
+ Logo = _logo,
Phone = _phone,
PostalCode = _postalcode,
Country = _country,