how to use custom files on a webserver
creeperita09 opened this issue ยท 1 comments
so i have a webserver in express.js that serves some custom audio files that i want to use on etched tho i get everytime this error:
[12:30:06] [Worker-Main-7/ERROR] [gg.mo.et.ap.so.AbstractOnlineSoundInstance/]: Failed to load audio from url: https://creeperita104.is-a.dev/rickroll.mp3
java.io.IOException: The provided URL is a stream, but that is not supported
at gg.moonflower.etched.api.sound.source.AudioSource.downloadTo(AudioSource.java:146) ~[etched-3.0.2.jar%23503!/:?] {re:classloading}
at gg.moonflower.etched.api.sound.source.RawAudioSource.lambda$new$0(RawAudioSource.java:24) ~[etched-3.0.2.jar%23503!/:?] {re:classloading}
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?] {}
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] {}
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] {}
at java.lang.Thread.run(Thread.java:833) ~[?:?] {re:mixin}
the server code is this:
const express = require('express');
const path = require('path');
const fs = require('fs');
const app = express();
app.get('/rickroll.mp3', (req, res) => {
const filePath = path.join(__dirname, 'rickroll.mp3');
fs.stat(filePath, (err, stats) => {
if (err) {
console.error('Error while getting file stats:', err);
res.status(500).send('Error while getting file stats.');
return;
}
res.setHeader('Content-Type', 'audio/mpeg');
res.setHeader('Content-Disposition', 'attachment; filename="rickroll.mp3"');
res.setHeader('Content-Length', stats.size);
res.setHeader('Accept-Ranges', 'bytes');
res.sendFile(filePath, (err) => {
if (err) {
console.error('Error while sending the file:', err);
res.status(500).send('Error while sending the file.');
}
});
});
});
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});