-
Notifications
You must be signed in to change notification settings - Fork 5
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
0e3d560
commit b192f93
Showing
9 changed files
with
105 additions
and
101 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
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 |
---|---|---|
@@ -1,28 +1,23 @@ | ||
export function getBase64(img:File, callback:Function) { | ||
export function getBase64(img: File, callback: Function) { | ||
const reader = new FileReader(); | ||
reader.addEventListener("load", () => callback(reader.result)); | ||
reader.readAsDataURL(img); | ||
} | ||
|
||
// export function dataURLtoFile(dataURL:string, filename:string) { | ||
// const arr = dataURL.split(','); | ||
// const expectedMimeTypes = ['image/jpeg', 'image/png']; | ||
|
||
|
||
// const match = arr[0].match(/:(.*?);/); | ||
// if (!match) return null; | ||
|
||
// const mime = match[1]; | ||
|
||
// if (!expectedMimeTypes.includes(mime) ) return null; | ||
|
||
// const bstr = atob(arr[1]); | ||
// let n = bstr.length; | ||
// const u8arr = new Uint8Array(n); | ||
|
||
// while (n--) { | ||
// u8arr[n] = bstr.charCodeAt(n); | ||
// } | ||
|
||
// return new File([u8arr], filename, { type: mime }); | ||
// } | ||
export function getAvatarSrc( | ||
avatarPreview: null | string | undefined, | ||
userPhoto: string | undefined, | ||
API_URL: string | undefined | ||
): string | undefined { | ||
if ( | ||
typeof avatarPreview === "undefined" && | ||
typeof userPhoto === "string" && | ||
userPhoto.startsWith("/uploads/") | ||
) { | ||
const previewUrl = `${API_URL}${userPhoto}`; | ||
console.log("previewUrl", previewUrl); | ||
return previewUrl; | ||
} else { | ||
return userPhoto; | ||
} | ||
} |
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
Oops, something went wrong.