Skip to content

Commit

Permalink
download file at /drive/:id instead of with ?id
Browse files Browse the repository at this point in the history
  • Loading branch information
patheticGeek committed Jun 27, 2020
1 parent c96401f commit 0b7b37c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ server.use("/api/v1/drive/folder", async (req, res) => {
res.send(await getFiles(folderId));
});

server.use("/api/v1/drive/file/:slug", sendFileStream);
server.use("/api/v1/drive/file/:id", sendFileStream);

server.use("/api/v1/drive/getAuthURL", (req, res) => {
const CLIENT_ID = req.query.clientId;
Expand Down
3 changes: 2 additions & 1 deletion utils/gdrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ function getFiles(folderId) {
}

function sendFileStream(req, res) {
const fileId = req.query.id;
const fileId = req.params.id || req.query.id;
if (!fileId) res.sendStatus(404);
drive.files.get(
{
fileId,
Expand Down

0 comments on commit 0b7b37c

Please sign in to comment.