我从Socket创建AudioInputStream时遇到问题.以下是重要部分:
public class SoundStream extends Thread {
private int port;
private String IP;
private Socket socket;
private SoundObject soundObject;
private OpenAL openAL;
private Source source;
private boolean run = true;
public SoundStream(int port, String IP, SoundObject soundObject) {
this.soundObject = soundObject;
this.port = port;
this.IP = IP;
}
public void run() {
try {
this.socket = new Socket(this.IP, this.port);
this.openAL = new OpenAL();
} catch (Exception e) {
e.printStackTrace();
}
this.mainCycleMethod();
}
private void mainCycleMethod() {
while (run) {
this.soundObject.blockAndWait(); …Run Code Online (Sandbox Code Playgroud) 我有一个联系人列表,每个联系人都有一张存储在Firebase存储中的个人资料照片.获取图像的官方方法是使用Firebase存储SDK获取URL并将其设置为img元素中的src.
firebaseApp.storage().ref("profilePhotos/" + officeId + ".jpg").getDownloadURL().then(function (url) {
this.photoUrl = url;
}.bind(this)).catch(function (error) {
console.log("Photo error"); // TODO: handler
});
Run Code Online (Sandbox Code Playgroud)
当我必须加载多个文件时(例如在联系人列表中),这非常麻烦.上面收到的文件URL是静态的吗?我可以将它存储在配置文件信息中的数据库中并直接使用吗?
谢谢
javascript firebase firebase-realtime-database firebase-storage
我在Firebase托管上托管单页应用,我需要允许跨域请求到应用引擎.应用程序托管在project-id.firebaseapp.com上,app-引擎服务托管在project-id.appspot.com上.我重新部署了部署文档,没有示例如何为URL添加Access-Control-Allow-Origin标头.
这是我的firebase.json的样子:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public",
"redirects": [
{
"source": "/server/:rest*",
"destination": "https://app-id.appspot.com/:rest*",
"type": 301
}
],
"rewrites": [
{
"source": "/views/**",
"destination": "/views/**"
},
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [ {
"source" : "https://app-id.appspot.com/registration/generate",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
} ]
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用gsutils设置CORS,但它也没有帮助:
这是我的cors.json
[
{
"maxAgeSeconds": 3600,
"method": ["GET", "POST"],
"origin": ["https://project-id.appspot.com/"]
}
]
Run Code Online (Sandbox Code Playgroud)
提前致谢
解:
如果您只想在静态文件上允许CORS,那么在app.yaml中设置Access-Control-Allow-Origin标头就足够了.对于动态请求,此标头不允许在app.yaml中,因此您必须以编程方式添加它. …