-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add 'getUserMedia' query to backend to simplify the frontend
- Loading branch information
viet nguyen
committed
Apr 28, 2023
1 parent
d3f1fb2
commit 1619caf
Showing
7 changed files
with
211 additions
and
57 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Storage } from '@google-cloud/storage' | ||
|
||
const storage = new Storage({ | ||
projectId: 'openbeta', | ||
credentials: { | ||
type: 'service-account', | ||
client_email: '[email protected]', | ||
private_key: '' | ||
} | ||
}) | ||
|
||
/** | ||
* Get a user's media files. May not need this. | ||
* @param uuidStr user id in uuid v4 format | ||
* @returns a list media objects including associated tags | ||
*/ | ||
export const getUserMedia = async (uuidStr: string): Promise<string[]> => { | ||
const [files] = await storage.bucket('openbeta-staging').getFiles({ | ||
autoPaginate: false, | ||
prefix: `u/${uuidStr}/`, // | ||
delimiter: '/' | ||
}) | ||
return files.reduce<string[]>((acc, curr) => { | ||
if (!curr.name.endsWith('.json')) { | ||
acc.push(`/${curr.name}`) | ||
} | ||
return acc | ||
}, []) | ||
} |
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