forked from b00tc4mp/isdi-parttime-202309
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add downloadFile logic & handler b00tc4mp#361
- Loading branch information
Abel Prieto
committed
Mar 12, 2024
1 parent
25a7d00
commit feac0e5
Showing
11 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
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
Empty file.
Empty file.
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,14 @@ | ||
import mongoose from 'mongoose' | ||
import downloadFile from '../logic/downloadFile.js' | ||
|
||
mongoose.connect('mongodb://127.0.0.1/hiinit') | ||
.then(() => { | ||
try { | ||
downloadFile('65e8bd456728f7c2d66bd330', '65eb3695de39ba551ad01d77') | ||
.then(() => console.log('file successfully download!')) | ||
.catch(error => console.error(error)) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
}) | ||
.catch(error => console.error(error)) |
20 changes: 20 additions & 0 deletions
20
staff/abel-prieto/PROYECT/API/test/html_test/downloadFile.test.html
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,20 @@ | ||
<script> | ||
const req = { | ||
method: 'GET', | ||
headers: { | ||
'Authorization': 'Bearer 65e8c8c89653e312c3490947' | ||
} | ||
} | ||
|
||
fetch('http://localhost:9001/download/65ef4d6574acbaf3bf0c839d', req) | ||
.catch(error => console.error(error)) | ||
.then(res => { | ||
if (res.ok) { | ||
res.json() | ||
.catch(error => console.error(error)) | ||
.then(body => console.log(res.status, body)) | ||
} else { | ||
console.error(res.status) | ||
} | ||
}) | ||
</script> |
Binary file removed
BIN
-19.9 KB
staff/abel-prieto/PROYECT/API/uploads/249f746ae5a9de637a9c73d6ddaf50a8
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.