Мне было интересно, если вы можете позвонить создать запрос GET на сервере RESTApi для загрузки файла. Например, если бы я вызвал запрос GET
на http://<IP>/storage/download/:filePath/
, он бы скачал этот файл. Я пишу RESTAPi в nodejs.
const express = require('express');
const router = express.Router();
const fs = require('fs');
const path = require('path');
const root = {}
//for this example say filepath = api%2Fstorage%2FImages%2FtestPhoto.png or api/storage/Images/testPhoto.png
router.get("/download/:filePath", (req, res, next) => {
var filePath = req.params.filePath;
filePath = decodeURIComponent(filePath)
res.sendFile(filePath);
// this is what im questioning. If i use this will it send the file? if so how will i download it on the front end?
})