JQuery Media Plugin playing file outside the webroot - javascript

Is it possible to play a media file which is outside the webroot using the Jquery Media Plugin. The server that we are on is windows based. The file path for example is:
\server\share\music.mp3
In my testing so far it does not seem possible.

You won't be able to reference it directly, no. But you could pass it through a local serverside script, making your request-path something like:
getmusic.php?id=music
The getmusic.php script will have access to non-public directories. It can read the mp3 contents, and then spit them back out to the end-user. Be sure to be very skeptical of all requests to this file though, since it opens up the possibility for security-issues.

Related

pass secure file to pdf.js/viewer.html with php

I am experimenting with the pdf.js examples, and in particular the viewer.html/viewer.js. I am trying to access a URL outside of the webroot. My PHP installation has access to a specific folder outside webroot where I store pdf files. In PHP I stream these files to the browser for download, which works fine. However, I would like to also stream the file to the viewer directly. Is that possible?
So, for example, my URL would be /web/viewer.html?file=12345.pdf for a file that is accessible to the web browser.
However, if I want to stream this from outside the root, the URL may look like this: /web/viewer.html?file=fetch.php?id=12345
Any idea how I should go about this, as the viewer seems to fetch the filename directly.
One idea I explored is to create a temporary copy within webroot. Pass that file to the viewer and delete the file after a set period to ensure it was loaded. That seems awfully inefficient, so somehow passing the file directly to the viewer so it can be used without creating a temp copy seems to be a better approach, if possible. Any ideas are much appreciated.

Squarespace Developer Mode adding files

I am in developer mode in the .region file trying to add a background video with the video tag. I put the mp4 file into the template folder and I have been trying to access it through src="video.mp4" and display the video. It doesn't display the video and I am not sure why I can't grab it. When i change the source to any http// video online it works so its not the code. It only doesn't display the video when I try grabbing it from the local folder. Any leads or help would be appreciated. Thank you!
Files that are directly located in the /template folder are not intended to be accessible via http. Instead, put the file within /template/assets and then reference the file as /assets/video.mp4.
If that doesn't help, ensure that the file is even accessible via http by entering http://yoursite.squarespace.com/assets/video.mp4 in the address bar (using your site's correct URL). If you can access the video file, then it will work as a src attribute of a video element. If you cannot access it, then something else is going on: either you haven't uploaded the file or the file name is incorrect.
Another tip: if using the full URL for a file (as opposed to the relative URL), try using https for the protocol in place of http. The correct protocol depends on your site's settings, of course, and whether you are using your built-in or custom domain.
If using the local development server via Node.js (as opposed to the live server, that is, your actual Squarespace site), try pushing/uploading the files to the live server on Squarespace (via Git or SFTP) and then retesting locally. I've found that sometimes this may be required due to caching in the local environment. This will also reveal whether the file you are uploading is too large (the documentation does claim a 1MB limit which may be true, though it may be as large as 5MB or 20MB if the docs are out of date; I cannot recall whether this has changed).
If the file is too large for the /assets folder, then your only other option besides hosting it via a different service entirely is to use the file storage via the Squarespace Config UI, which allows up to 20MB, and referencing your video via that path. You'd have to get the video down to 20MB by shortening, scaling or further compressing it.
If hosting the file via a different service, Cloudinary may be worth considering; a free account may allow up to a 100MB video file and enough bandwidth (assuming your website's traffic is relatively low).

It it possible to use javascript to save a file to specific directory?

Used Filesaver.js plugins to download a text file. By default file download in My download folder. Need to store the downloaded file in a specific folder.
It is not possible... fortunately! Imagine what would happen if JS which runs in your browser could change your filesystem. The security hole would be so big that everyone would (and definitely should) stop using the Internet. Imagine a situation where I've built a website which onload fires the code which save a file in your filesystem. The file lands in your cron.daily directory (suppose you use Linux). What is the file doing? - you may ask (if you knew that it's been even saved :smiling_imp:). Nothing special - just looking for some private data and when finished it deletes random files from /usr/bin, /proc, /sys and maybe /etc - just to see what happens.
Do you see the problem now? The code which runs in your browser before you can react to this cannot have such power to save anything in your filesystem. The only thing you can do to give the user a file is to use a module like Filesaver.js which, in fact, does not have access to user's file system at all. It just makes a GET request to the file directly and it's the browser which downloads the file (because that's how a browser works). So the only way you can change the location of the downloaded file is to change the browser settings. No other way I know of.
The answer is No,
changing a directory is not possible due to security reasons in the
File API.
https://github.com/eligrey/FileSaver.js/issues/42

Save data in a local file with HTML, Javascript?

I'd like to develop a simple offline html page to track my working hours. I'd need an offline file where I can put all my information and then retrieve them through Javascript. What do you suggest me? XML, Json, a DB? I need a "physical" local file because I would like to take my folder with all my html, css, and js files, put it in a pen drive and then open it in another computer. So something portable.
You can't do that offline; HTML/JavaScript doesn't have the ability to write to the filesystem. You can create cookies or use .localStorage in JavaScript, but that would only be local to your browser and won't be visible on another computer.
The closest thing you could possibly get is to write a page that stores data in localStorage and then run it from a portable version of your favorite browser that you also keep on your portable drive.
If you are not set on only using HTML, you might look into doing a C# windows form application.
You can find more on how to leverage that StreamWriter Class here:
https://msdn.microsoft.com/en-us/library/system.io.streamwriter(v=vs.110).aspx
However as for file type, a local JSON or .csv file should do the trick.

Possible download / upload manager embedded on html page with access to local filesystem

As the title indicates i want to have a certain application get access to the local file system. To describe why i will illustrate my situation:
I am a running a IIS WebApplication with the C# MVC 4 Framework as backend module. The site solely consists of HTML, CSS markup and some JS. The page will be loaded in IE11+ (Edge) only. For the standard procedure of displaying and accessing data from as well as sending data to the server this works quite fine.
On a certain page I want the user to be able to upload a file using a simple file dialog, like the one you can initiate with a simple <input type="file"> tag. I also want to offer the posibility to download files from the server but need to know where files has been saved / will be saved to.
As described on a lot of different websites, just like this one here, the HTML5 File API does a great job but will not be able to return the full qualified filename including the local path directions, same for JS accessing the file object.
As my research confirmed HTML5, JS and also SWF (Flash) will not report detailed information because they are all sandboxed applications or restricted by RFCs. I already unterstood and appreciate the effort to secure my trips to internet.
But in this case do need the paths where a file was upload from and the file has been downloaded to.
So my question is, what is the best way to expose the full path directions for a up- as well as downloaded file to report them back to the server?
Is it possible to embed a SWF object inside HTML which will run inside an Adobe AIR sandbox or is a signed JAVA Applet still the one and only solution to accomblish this security breaking task?
A solution i would also apreciate would be the possiblity to ask the user to get access the file system, like you grant access to the web push service to receive notifications.
Also if there is a possible solution which may suite my circumstances please let me know by adding some simeple examples / revealing some factful links, thanks in advance.

Categories