Load Audio from persistentDataPath in runtime (Unity3d WebGL) - unity3d

I have online/offline project.
I need to download wav/ogg/mp3 file from Application.persistentDataPath on WebGL platform.
I tried www/webrequest.
For example - WWW("file://" + Application.persistentDataPath + filePath);
But always get error: Failed to load: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Could you help me?
P.S. From remote server works fine.

You can not load local files in a browser as it's a security risk. If you could then a webpage could read your hard drive and steal all your files.
If you're just testing you can run a local server.
If you want to let the user supply a file you can let them choose a file

Related

How to disable teamcity server url autodetection or fix server url manually?

I have my Teamcity instance been setup by defaults. Its behind nginx, so i had moved /WWW folder to /teamcity folder and had set nginx location record up like that.
location /teamcity {
proxy_pass http://localhost:8111/teamcity;
# and a couple of _sets here
}
everything works fine except Nuget feed. I can list packets from it but i cant download any packet because the packet URL.
It looks like:
1. http://some.domain.com:443/teamcity/whatever/url/for/the/packet/(correct one)
instead of:
2. https://some.domain.com/teamcity/(correct URL)
The packets at the second URL are accessible but feed returns me firs one. URLs in "General Settings" and "main-config.xml" are correct also. Is that because of URL auto detection, so can i disable it some how or is it because of another issue?
Server URL autodetect is not related to this problem. If you have custom URL specified, then autodetect will be disabled.
Make sure you pass all necessary headers as specified in our documentation: https://confluence.jetbrains.com/pages/viewpage.action?pageId=74845225#HowTo...-NGINX

How to get AssetBundleManifest in Unity3D

Following the instructions on the official site https://docs.unity3d.com/ScriptReference/Caching.html I fail to get AssetBundleManifest neither from the server nor from local storage. The end goal is to get AssetBundle’s hash.
Main error message in the console is:
Failed to decompress data for the AssetBundle "Memory"
I tried to use the following:
UnityWebRequest - to load from server
LoadFromFile - to local from local storage
How to do it correctly?

Parse Server - Can't Access Images

I have a Parse Server running on top of a MongoDB, and that's running 100% fine on my Dev Server which is hosted on DigitalOcean. Here I'm able to send GET requests to my server to obtain the image, as well as access the image via it's Parse-Dashboard.
I cloned that droplet to set up a Production Server, and everything is running fine... Except, I can't access the images from Parse that were either cloned from the Dev Server, or ones that I uploaded after I initialized the new Production server. I'm able to send GET requests to obtain all other fields, except for the image files. I also can't access the image file via the Parse-Dashboard - it returns a 404 - Oh no, we can't find that page! error, on the following URL: http://server.ip/parse/files/ProdServer/de632aeb61f7265926e554fabfb25180_image1.png
Other key things to note:
The Dev Server is hosted on a domain that has a SSL; could it be an SSL issue?
I'm initializing the parse-dashboard with the --allowInsecureHTTP flag
Everything (even before the SSL) was working on the Dev Server beforehand
all packages + dependencies are up-to-date
tl;dr
How do I access the image files from my Parse Server, via Parse-Dashboard or GET request?
A couple methods I tried... Since this was an elaborate process for me, allow me to document the methods I tried to resolve this issue:
The first issue was, do the files exist? If so, where are they stored?
By accessing my parse-dashboard on port 4040, I tried to view the image path via the URL... So I knew it existed somewhere, and I recursively searched my entire server for the file path, but to no avail.
Then with more research I found that any file over 16MB gets converted into a GridFS object i.e. images are stored in my MongoDB. How you access these objects are through a utility called mongofiles.
By running mongofiles -d dbname list I was able to view in a list view all of the images stored on my Parse-Server.
just to ensure the images weren't corrupt...
I also sftp the images over into my local machine, and fortunately I could view them. So the problem was that the images weren't being served correctly...
The next issue was, how come the images aren't being served correctly?
So my parse-dashboard was being served on port 4040, but for some reason, my image file path within their respective URLs were being prefaced with the same port 4040... It turns out that within my Parse-Server config, the parse-server URL was pointing to port 4040, but was being served on ****. By changing my URL back to ****, my images were able to properly render on my parse-dashboard, and I was able to send http requests for the images as well :)
tl;dr make sure your image file path is being served on the same port where your parse-server is being served

How to load local files from user selected directory in chrome app

I am developing chrome app , in my app user can download external content to their local directory , to access user's file system i am using chrome.FileSystem API ,i can access user's local directory and i am also able to write downloaded content to their directory by keeping user selected directory to localStorage.
My problem is i want to open these files in main html file using either webview / iframe , it will be better if its possible with iframe but i am getting error in both cases -
to get full path i am using below code -
chrome.fileSystem.getDisplayPath(chosenEntry, function(path) {
console.log("path"+path);
// for now i am adding static path to it for testing purpose
var finalPath = path+'/folder/index.html'; //Here finalPath is a valid path , can be accessible from browser
});
if i load it using iFrame -
Refused to frame 'path' because it violates the following Content Security Policy directive: "frame-src 'self' blob: filesystem: data: chrome-extension-resource:".
When i tried using webview -
: The load has aborted with error -301: ERR_DISALLOWED_URL_SCHEME.
I have also tried by giving permission in manifest.json file -
"permissions": [
"file:///*"
]
Note : user may have number of downloaded content each with their own folder , so i have to open any of these according to user action.
It's not the most elegant solution, but running a web server inside chrome your chrome app and pointing the webview at the web server URL will work.

freeswitch stream remote audio file

i'm saving the remote audio files on google cloud storage.
i want to play these files in freeswitch.
when i use:
mediaLink = "http://storage.googleapis.com/myBucket/file.wav";
session:streamFile(mediaLink);
it works great.
But when i use signed urls
mediaLink = "http://storage.googleapis.com/myBucket/file.wav?GoogleAccessId=xxx-xxx#developer.gserviceaccount.com&Expires=1408903962590&Signature=xxb%2Fx%2FDfGJlrUuz0%2F6kA6ormmReW6oN%2F0xxy3%2BwWxXc%3D";
session:streamFile(mediaLink);
i get this error:
2014-08-24 20:42:48.770818 [ERR] mod_httapi.c:2696 File at url [http://storage.googleapis.com/myBucket/file.wav?GoogleAccessId=xxx-xxx#developer.gserviceaccount.com&Expires=1408903962590&Signature=xxb%2Fx%2FDfGJlrUuz0%2F6kA6ormmReW6oN%2F0xxy3%2BwWxXc%3D] is unreachable!
Thanks,
Snabel
Was able to get this to work with playback from mod_dptools and mod_shout (for mp3 support) on FreeSWITCH 1.10. The Google Storage signing algorithm is also at V4 at the moment.
Testing workflow:
$ gsutil signurl -r us service-account.json gs://the-bucket/a-song.mp3
URL
gs://the-bucket/a-song.mp3
HTTP Method
GET
Expiration
2019-08-24 19:03:02
Signed URL
https://storage.googleapis.com/the-bucket/a-song.mp3?x-goog-signature=a4d1dc28eeebfcdfd09f00cbc1bbe605590df3773fd473a9bcc961928bd0a64bc9ea6367a7c2de98cb5f397529bd82f455651b1d04fc1650c97587fb3c298ab49ee6dfc9092068a09612b30b9707595af4705d904e8a63b8fd3e4fcf3eb6767635d2ffb77f036b58e2cae39c7ac571bd520ef5e49435599b6f9871d1bbd43d4e1329a1af1274c15ff63731f058c61cdc693e4c5d85cbeca8b3c5886a9f1d86bfa196ea89300bccd103c66c4dec0000caa80cee5f5cbd748312dc1288c33800750313e9534bfbd8ecbd23bec31fa7c97dd0fcc1581c3353fa38e09c1e888fd8c07766059e63e14579fa44d25a57231ab4504265217c8a8225bdd68983bf6570dd&x-goog-algorithm=GOOG4-RSA-SHA256&x-goog-credential=name-of-the-service-account%2F20190824%2Fus%2Fstorage%2Fgoog4_request&x-goog-date=20190824T183009Z&x-goog-expires=3600&x-goog-signedheaders=host
Using playback with the FreeSWITCH Lua API's IVRMenu (examples) (here's the full application code):
-- signed URL above stripped of the URL scheme
local signed_url_without_url_scheme = "storage.googleapis..."
i.unregistered_main:bindAction(
"menu-exec-app",
"playback shout://" .. signed_url_without_url_scheme,
"3"
)
I had no luck with streamFile, but not because of the signed URLs, but because I couldn't even get it to work. The documentation is very spotty, and certain sections even contradict each other (compare mod_shout and session:streamFile for example).