How to get file in Silverlight Application? - silverlight

Suppose, we have a sivlerlight application - SLApp. SLApp is located on the WebSite someweb.com. Link on file likes this - someweb.com/SLApp?URL="https://smthg.com/file.exe" .
How to get this file in the silverlight app&

It's difficult to understand what you want from your question:
For getting a file from the client machine and sending it to the server:
You can't do that directly, it's a security risk, and hence disabled. You can only access files via the file open dialog.
For getting a file from the server to the client:
Now if you are wanting to download a file to the client via a link, then you can just open a web page with the link/url, that way you use the standard browser functionality.

Related

how to read data from a properties file in reactjs

I have created properties file in other directory of my computer. I want to read the data from that file and display it. So can anyone please suggest me, How can I achieve this.Thanks in advance.
From what i understand, you have a properties file on YOUR computer and you want to read that file from reactjs app. This is not possible as front end is not allowed to directly access user's hard disk. This would be a big security flaw. This is because the front end part runs on the client side.
Consider a situation where you have written code to read file from desktop. Then your app would be able to read the desktop files of ALL USERS who use that app. That's why you always see an upload button when you have to choose a file to read. The file is first sent to server side and then processed.
Since reactjs runs on client side, it is better to maintain a server and make an API call to it to fetch the data. Or you can hard code it in react app itself if it isn't sensitive info.
On front-end side - You can't and You should not be able to because it'd be a huge security risk. Do not try to solve it on the client side. Try to think about a back-end solution after uploading that particular file to the server.
On the other hand - why are you trying to keep a file, which is logically connected with the app - outside of the repository ?
Since its not clear what you are trying to achive,
Situation 1. You developed a react app for users, which is trying to read a user's file on his computer.
This is not possible as reactjs is a front-end library which can access the resources limited to browser only. You just can't read someone else's files.
Situation 2. The file is a part of you project which is in different directory.
So just put your file inside the your project directory, and since it is a properties file then this is how you can import it inside your project.

How to create folders and images using AngularJS

I have an AngularJS app that, upon requested to upload an image, creates a folder inside the file system (CentOS) and then puts that image there, telling the user everything went OK or not.
Is this possible? All I've found is ways to download the file.
Thanks.
It is better to delegate this task to a service on the server, since it is file that is uploading to a server. I put simple rest service to file upload this file to the server.

Upload file is not working using AngularJS on lighttpd server

In my current project we are using lighttpd server. Here I am trying to upload the file. I am getting two Response Headers, first is with 301 Status code (Moved Permanently) and second is with 200 (OK).
But when I am checking in the folder I am not able to find any file (I mean no file uploaded).
I have tried both way to upload file as given links below:
http://jsfiddle.net/danialfarid/0mz6ff9o/135/
ngFileUpload
https://jsfiddle.net/JeJenny/ZG9re/
In both way I am getting the same response.
So here I have some sort of questions:
1) Is file upload is possible using AngularJS only? (No Server Side Script)
2) If possible, Is there any config problem with lighttpd?
Thanks !
Need Help...
The server side (or any web server) must be configured to handle POST and PUT requests. CGI, FastCGI, SCGI scripts can be written, or you can proxy to another backend. For simple file uploads, lighttpd also provides mod_webdav which you can configure (and protect with mod_auth) to allow you to upload files without having to write any server-side code.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModWebdav

The name of a created PDF is not transferred from the server to the client (GWT - GAE)

I develope a GWT-application which creates a PDF-file at the server, and then transferres it to the client.
At the client-side, a window appears which allows the user either to
open it with a program assigned to the file name ending, or
save it to disc.
I have read several threads to this topic, such as
How can a user download a file in client side (Google Web Toolkit)
GWT: Showing PDF created as POST response
How can a user download a file in client side (Google Web Toolkit)
and that helped me coding the doGet()-methode in my print-servlet like this:
resp.setContentType("application/octet-stream");
resp.setHeader("Content-Disposition:", "attachment; filename=\"" + fileName + "\"");
This works fine when testing and debugging using the local GWT-developement server.
But my big problem is:
After deploying to GAE and running the code on GAE, the created pdf-name is not transferred to the client...!
Instead of e.g. TestPdf-25072016.pdf, the name only consists of the word print.
This leads to the fact that the standard-program for a PDF is not invoked automatically when I want to open it. And, of course, print is not the name of the PDF I want to have...
Where is my failure? Especially I am confused that everything works fine when using the local developement server?
Thanks a lot for your support!
You could use a tool like Wireshark or Fiddler to capture the actual HTTP header sent to you when you call printing in GAE.
Maybe GAE is adjusting the header or just blocking it.

Silverlight Ftp Upload

I'm working on trying to ftp a file to the server through a silverlight application. Where the location to upload the file on server file system, exists outside the sandbox area for the web server. In this case the web server root exists at "C:\test\www\" and the location to upload the file will exist at "C:\User\Uploads". In this scenerio i'm not sure if Http POST will work (doesn't that use the web server root). I just need to upload the file selected by the user to a different location that may exist outside the sandbox. With silverlight i'm thinking sockets are my last option based on the limited port range for silverlight being 4502-4532. Can i do this using WebClient and Http POST? Can i make an ftp connection through silverlight or javascript?
This is an interesting scenario, since it sounds like you are doing this all on the same machine (both client and server). I am responding to the vague original question, and would love additional data to help answer this completely.
FTP uploading itself is not supported by Silverlight, but the concept of uploading a file is, through an HTTP stream of data.
If you want to do an HTTP upload from a client machine to the server: You can use the OpenFileDialog control in Silverlight 2 and 3 to read that data, then use WebClient to upload it.
If you want to do a download from something your web server can send, to the client machine, then you'd need to use Silverlight 3 or newer, which features a SaveFileDialog control.
All Silverlight file dialogs require a user-initiated action for them to work, function, and the user will need to select the file name(s) for security purposes.
Hope this helps!
Assuming your server is ASP.NET based I would use a simple WebClient POST into a .ashx handler. Have the handler write the body of the post to a file in "C:\User\Uploads".
As long as the ftp server is on the same host as the silverlight app you can use sockets and code your own ftp client, its not very hard and there's plenty of examples out there.
In the meantime, name it Silverlight 5, Sockets got an update: with ClientAccessPolicy.xml the port-range got boosted and an in-browser elevated-trust mode is available.
Therefore I've created sharpLightFtp to enable rudimental Ftp.

Resources