diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-07 17:08:49 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-07 17:08:49 -0400 |
commit | 32cd51e2bcc0a8cf498c0b31a5ead60802f672de (patch) | |
tree | e353f730591ee9b7d1a5661364679dc33fe38fa1 /src/server/index.ts | |
parent | d94509864920b2bbe7f4af8837f3af3f721b7dad (diff) |
working on import from google photos
Diffstat (limited to 'src/server/index.ts')
-rw-r--r-- | src/server/index.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/server/index.ts b/src/server/index.ts index 99d8a02d4..aadadb11a 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -113,7 +113,7 @@ function addSecureRoute(method: Method, ) { let abstracted = (req: express.Request, res: express.Response) => { if (req.user) { - handler(req.user as any, res, req); + handler(req.user, res, req); } else { req.session!.target = req.originalUrl; onRejection(res, req); @@ -848,6 +848,20 @@ app.post(RouteStore.googlePhotosMediaUpload, async (req, res) => { ); }); +app.post(RouteStore.googlePhotosMediaDownload, async (req, res) => { + const contents = req.body; + if (!contents) { + return res.send(undefined); + } + await GooglePhotosUploadUtils.initialize({ uploadDirectory, credentialsPath, tokenPath }); + let bundles: GooglePhotosUploadUtils.DownloadInformation[] = []; + await Promise.all(contents.mediaItems.forEach(async (item: any) => { + const information = await GooglePhotosUploadUtils.IOUtils.Download(item.baseUrl, item.filename); + information && bundles.push(information); + })); + res.send(bundles); +}); + const suffixMap: { [type: string]: (string | [string, string | ((json: any) => any)]) } = { "number": "_n", "string": "_t", |