I am required to allow a user to view a file in javascript, but not to able to download the file through a direct link.
Therefore the only solution remaining is to allow only the server to access the file, and serve it to javascript via php.
At the moment, the javascript plugin forces me to send a url to it:
loader.load('example.stl');
The external javascript then executes this:
prototype.load = function (url, callback) {
var scope = this;
var xhr = new XMLHttpRequest();
function onloaded( event ) {
if ( event.target.status === 200 || event.target.status === 0 ) {
var geometry = scope.parse( event.target.responseText );
scope.dispatchEvent( { type: 'load', content: geometry } );
if ( callback ) callback( geometry );
} else {
scope.dispatchEvent( { type: 'error', message: 'Couldn\'t load URL [' + url + ']',
response: event.target.responseText } );
}
}
xhr.addEventListener( 'load', onloaded, false );
xhr.addEventListener( 'progress', function ( event ) {
scope.dispatchEvent( { type: 'progress', loaded: event.loaded, total: event.total } );
}, false );
xhr.addEventListener( 'error', function () {
scope.dispatchEvent( { type: 'error', message: 'Couldn\'t load URL [' + url + ']' } );
}, false );
xhr.overrideMimeType('text/plain; charset=x-user-defined');
xhr.open( 'GET', url, true );
xhr.send( null );
};
Obviously the javascript file reads in the file as XML, however, I'm not experienced enough with Javascript to manipulate it to fit my needs.