Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use custom files on a webserver #105

Open
creeperita09 opened this issue Jul 15, 2024 · 1 comment
Open

how to use custom files on a webserver #105

creeperita09 opened this issue Jul 15, 2024 · 1 comment

Comments

@creeperita09
Copy link

creeperita09 commented Jul 15, 2024

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}`);
});
@creeperita09
Copy link
Author

like am i doing anything wrong here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant