-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from lyve-app/feat/upload-images
feat: added img upload for create stream and update user closes #85
- Loading branch information
Showing
13 changed files
with
152 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
BlobServiceClient, | ||
StorageSharedKeyCredential | ||
} from "@azure/storage-blob"; | ||
import config from "./config"; | ||
|
||
const sharedKeyCredential = new StorageSharedKeyCredential( | ||
config.azure.storage.account.name, | ||
config.azure.storage.account.key | ||
); | ||
|
||
export const blobServiceClient = new BlobServiceClient( | ||
`https://${config.azure.storage.account.name}.blob.core.windows.net`, | ||
sharedKeyCredential | ||
); |
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,5 @@ | ||
import multer from "multer"; | ||
|
||
const storage = multer.memoryStorage(); // Use memory storage | ||
|
||
export const upload = multer({ storage }); |
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,16 @@ | ||
import config from "../config/config"; | ||
import { blobServiceClient } from "../config/azure"; | ||
|
||
export const uploadFileToBlob = async ( | ||
buffer: Buffer, | ||
blobName: string | ||
): Promise<{ url: string }> => { | ||
const containerClient = blobServiceClient.getContainerClient( | ||
config.azure.storage.container.name | ||
); | ||
const blockBlobClient = containerClient.getBlockBlobClient(blobName); | ||
await blockBlobClient.uploadData(buffer); | ||
|
||
// Return the URL of the uploaded file | ||
return { url: blockBlobClient.url }; | ||
}; |
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