Fixed Upload and Download
This commit is contained in:
parent
bb9a1e7f82
commit
b6b91fcc1a
|
@ -44,7 +44,7 @@ function DownloadFile() {
|
||||||
|
|
||||||
const handleDownloadFile = () => {
|
const handleDownloadFile = () => {
|
||||||
if (passcode) {
|
if (passcode) {
|
||||||
axios.get(`${apiUrl}/api/files/${passcode}/`, {responseType: 'blob'})
|
axios.get(`http://${apiUrl}/api/files/${passcode}/`, {responseType: 'blob'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let filename = 'downloaded_file'; // Default filename
|
let filename = 'downloaded_file'; // Default filename
|
||||||
let mimeType = 'application/octet-stream'; // Default MIME type
|
let mimeType = 'application/octet-stream'; // Default MIME type
|
||||||
|
|
|
@ -53,7 +53,7 @@ function ShareFile() {
|
||||||
|
|
||||||
// Send POST request to the backend API using Axios
|
// Send POST request to the backend API using Axios
|
||||||
axios
|
axios
|
||||||
.post(`${apiUrl}/api/files/`, formData)
|
.post(`http://${apiUrl}/api/files/`, formData)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// Handle a successful response from the server, set passcode to "key" in the response body
|
// Handle a successful response from the server, set passcode to "key" in the response body
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
|
@ -61,7 +61,7 @@ function ShareFile() {
|
||||||
// If data is an array, take the first item
|
// If data is an array, take the first item
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
const passcode = data[0].key;
|
const passcode = data[0].key;
|
||||||
const baseUrl = '${apiUrl}/api/files/';
|
const baseUrl = 'http://' + apiUrl + '/api/files/';
|
||||||
|
|
||||||
setPasscode(passcode);
|
setPasscode(passcode);
|
||||||
setShareableLink(baseUrl + passcode);
|
setShareableLink(baseUrl + passcode);
|
||||||
|
|
Loading…
Reference in New Issue