forked from TryCatchLearn/DatingApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648a270
commit d7b2fea
Showing
26 changed files
with
385 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -475,3 +475,4 @@ $RECYCLE.BIN/ | |
|
||
# Windows shortcuts | ||
*.lnk | ||
API/appsettings.json |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Security.Claims; | ||
|
||
namespace API.Extensions; | ||
|
||
public static class ClaimsPrincipalExtensions | ||
{ | ||
public static string GetUsername(this ClaimsPrincipal user) | ||
{ | ||
return user.FindFirst(ClaimTypes.NameIdentifier)?.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace API.Helpers; | ||
|
||
public class CloudinarySettings | ||
{ | ||
public string CloudName { get; set; } | ||
public string ApiKey { get; set; } | ||
public string ApiSecret { get; set; } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using CloudinaryDotNet.Actions; | ||
|
||
namespace API.Interfaces; | ||
|
||
public interface IPhotoService | ||
{ | ||
Task<ImageUploadResult> AddPhotoAsync(IFormFile file); | ||
Task<DeletionResult> DeletePhotoAsync(string publicId); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using API.Helpers; | ||
using API.Interfaces; | ||
using CloudinaryDotNet; | ||
using CloudinaryDotNet.Actions; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace API.Services; | ||
|
||
public class PhotoService : IPhotoService | ||
{ | ||
private readonly Cloudinary _cloudinary; | ||
public PhotoService(IOptions<CloudinarySettings> config) | ||
{ | ||
var acc = new Account | ||
( | ||
config.Value.CloudName, | ||
config.Value.ApiKey, | ||
config.Value.ApiSecret | ||
); | ||
|
||
_cloudinary = new Cloudinary(acc); | ||
} | ||
|
||
public async Task<ImageUploadResult> AddPhotoAsync(IFormFile file) | ||
{ | ||
var uploadResult = new ImageUploadResult(); | ||
|
||
if (file.Length > 0) | ||
{ | ||
using var stream = file.OpenReadStream(); | ||
var uploadParams = new ImageUploadParams | ||
{ | ||
File = new FileDescription(file.FileName, stream), | ||
Transformation = new Transformation().Height(500).Width(500).Crop("fill").Gravity("face"), | ||
Folder = "da-net7u" | ||
}; | ||
uploadResult = await _cloudinary.UploadAsync(uploadParams); | ||
} | ||
|
||
return uploadResult; | ||
} | ||
|
||
public async Task<DeletionResult> DeletePhotoAsync(string publicId) | ||
{ | ||
var deleteParams = new DeletionParams(publicId); | ||
|
||
return await _cloudinary.DestroyAsync(deleteParams); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export interface User { | ||
username: string; | ||
token: string; | ||
photoUrl: string; | ||
} |
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
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
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
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
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
7 changes: 7 additions & 0 deletions
7
client/src/app/members/photo-editor/photo-editor.component.css
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.nv-file-over { | ||
border: dotted 3px red; | ||
} | ||
|
||
input[type=file] { | ||
color: transparent; | ||
} |
Oops, something went wrong.