Configure flex sandbox for server local files - actionscript-3

I developed a flex application that loads images from the fileSystem. You just specify the path to the image, then the app brings some data from local webservices, and then flex loads the image and shows them to the user in an specific way.
I tested it by running the application from FlashBuilder as a WebApplication... so far no problems at all. However when loading the swf from a webpage, on a deployment environment (I.E: JBoss as the web application server) it doesn't loads anything...
My guess is that since now the swf is on the web server context, it can't load files from the local filesystem (I.E: /Users/username/files/myFile.jpg)... is this correct?? If it is... then what should I do in order to load the files correctly?? Or should I upload the files on the server first and then set the file path to an URL pointing to my web server resources?
Thanks a lot.

Flex is able to interact with the users file system without the need for httpservice middle ware. Meaning, I go to your your webpage with your flex app, I am able to load images from my filesystem to view in the app. However, if you want to the user to view images from the server that hosts the swf then you will need httpservice calls to a php, jsp, perl scripts or the like to get the data from your server.

Related

How can i create createReadStream of a video located in a different server from that where we host the application

I have a nestjs project in which I need to store the videos and save their paths in the mysql database my question is: how can I create a createReadStream of one of these videos knowing that the videos and the database will be in one server and the application in another server ??
fs.createReadStream() works just fine if you give it a full OS path. If you're having trouble with that, then we need to see what your "absolute path" is.
Usually, you would not store a full OS path in a database because that "hard wires" your implementation to a specific disk layout. Instead, you would usually store a relative path only in the database and then combine that with a base path that's part of the configuration of your app. That gives you more flexibility if you ever need to rearrange how things are stored on disk without having to rewrite every path in the database. Instead, you can just change the base path in your configuration to point to the new path.
For example, imagine you outgrow your current system disk and add a new faster and larger disk. When storing only relative paths in the database, you could shut-down your app, copy all the files over to the new disk, then adjust the base path in your app, restart your app and it would be up and running with the new location. If you had stored the absolute path in your database, you'd have to write a DB script tor rewrite every single path in the database to the new location.
can i host the database in one server and the application in anthor ? if yes how can i do that ??
The database can be wherever you want. But, the files themselves that you want to stream as a response to an http request will have to be accessible from the web server. If you want to use fs.createReadStream() as the source to stream them, then the files have to be accessible via an OS file path because fs.createReadStream() only works with a file path. If the files are stored elsewhere that doesn't have OS file path access to your web server (like say in a cloud service), you'd have to find some other way to read/stream them from your web server.
How can I create a createReadStream of one of these videos knowing that the videos and the database will be in one server and the application in another server
You can use fs.createReadStream() only if you have OS level file access to the other server (likely via some shared file system mechanism). For example, the files could be stored on some shared file server.
If you don't have OS level file access, then you will have to assess what type of access you do have and pick an appropriate mechanism for streaming the files from there. For example, if you have web access to the files (they are accessible via some URL), then you could either redirect the client to get the files directly from the other web server or you could stream them from that other server yourself using an http library that supports streaming such as got() or axios(). You could then pipe that http stream into your response - similar to what you would do with the stream from fs.createReadStream().

Local images in HTML

I'm an high school student and I'm working on something for fun. I've linked a local file stored on my computer to my webpage. What can I do to make it possible for other devices to access the local html file? (meme1.html)
<div id="button">
<a href="C:\Users\Desktop\MEME GENERATOR\meme1.html">
<img src="https://openclipart.org/image/2400px/svg_to_png/140365/1306313012.png" alt="Click here!" height="20%" width="20%"></a>
</div>
<div id="wrapper">
<h1><span class="tight-2">Happy Birthday!</h1>
<h2>Go ahead, press the button to generate memes!<span class="tm">™</span>.</h2>
</div>
Basically, when you host the site online you have to change the linked file path to the one of the server instead of your local machine.
Edit: If youre using plain HTML my answer stands, if you use a backend platform like Django, Flask or dotNet Core then the urls are dynamicly stated in your webapp.
By default, the local file is only available to the system it resides on. For instance this link you've created:
<a href="C:\Users\Desktop\MEME GENERATOR\meme1.html">
is telling the browser to look in the C: drive of the machine it's currently installed on. Every other system in your network (and the world, for that matter) will likely not be to pull that file because MEME GENERATOR isn't a folder on their system, so they will see a 404 (file not found) error.
That said, you can load links within your network by using network addresses. This will be the machine's network IP address, typically starting with 192.168.
That said, in order to load the file, the machine that it is running on will need to have a port open for the client machine's browser to connect to. This is typically port 80, unless SSL is in use, in which case it's typically port 8080, for HTTP traffic.
In doing so, the computer that is serving up the files becomes, logically, a 'server'. And this is the core of the client (user) to server relationship that the whole of the internet and networking is built upon.
Since you're on Windows, you can use something like XAMPP or WAMP to run a server locally that will have Apache installed, which can serve files through these ports. You're going to need to read up on these technologies a lot to get a file going, and be forewarned that this will open your system to hacking and the like.
EDIT: rereading your question, you are maybe trying to get this file to load on your website? If this is the case, then you need to upload the file to your website, and then it will have a folder structure similar to a local Windows file. [YOUR.DOMAIN.COM]/[whatever folder you create on your server in the public directory]/meme1.html
Do you mean? That you want other people to access your website?
Few ways to do that.
One thing you could do is to send the whole directory to the individual to who you want to send the webpage to.
Or the other way is what you can do is host the webpage on a hosting website. There are a lot of hosting websites that would host your websites for free.
That way anyone with a given URL can access the website.

Need to run .exe game file inside web page

I have a .exe game in a folder (it's running without setup) and need to upload it to my hosting so it can view and run it inside my website WordPress page, is it possible?
No, it would be very stupid and unsafe to give browsers the control to run any binary executable via any webpage

How To Upload A File On A Client Machine To My Server With JS, HTML, ETC?

Is it possible for a webpage on a remote client to upload a file from that remote client to my server without serverside ASP, PHP, etc? My server is an embedded webserver that can serve up html pages and service cgi commands but little else. I want it to serve a page to the client that allows the client browser to select a local file and upload it to my embedded server.
The http fileupload object is a perfect start for allowing the remote user to select the file they want to upload. But once they've selected the file how do I open it and send it to my embedded server? This is to be used to allow a remote user to upload a firmware update (binary file ~600k ish) to my embedded hardware using their web browser.
Thanks in advance for any help
~Tim
Nope. Server side is absolutely necessary to do any kind of uploading.
Sorry charlie

Access of the data by the server on the server machine

My question is I know that a server application can access the data stored at server but cannot access teh data stored at client machine as this is a security issue and Browsers not allow this. But in case of localHost (when my local pc is acting as a server) I should be able to access the files from my PC(the local PC on which the application is running). But that is not happening.
Why i m not able to access a simple image file form my local C:\ drive by localhost. The URL i used was file:///c:/image.png but if i store this image any where under home directory of tomcat i m able to access it. WHY ??
I m using it as <'img src="file:///c:/image.png>
Thanks for any considerations..
The problem is with this part:
The URL i used was file:///c:/image.png but if i store this image any
where under home directory of tomcat i m able to access it.
If you want to access the file through Tomcat after placing it in Tomcat's document-root, then the URL to use (assuming you haven't changed the default port setting) is:
http://localhost:8080/image.png
Content hosted by the web-server needs to be accessed through the web-server. A file:// URL bypasses any sort of server, and basically directs the browser to look directly in the local filesystem. So it should also work if you were to do:
file:///C:/path/to/tomcat/home/image.png
But in that case you are not going through Tomcat. You're just pointing the browser at the tomcat folder in your local filesystem.
Edit: I don't think many browsers will not allow file:// urls in tags in hosted documents. Doing so could cause the appearance of a security hole, as if you could guess the name of an image file on someone's local filesystem you could then post a webpage that made it appear as if your server had somehow grabbed their personal image file.