I have a web app that will run on a local computer, not from a server. I want to create some files and write data to them, but the packaged functions for TestOutPutStream, etc won’t work in a Web App. How can I create the files manually so I can write to them. Thanks for any assistance with this.
Just use the first example at http://documentation.xojo.com/index.php/TextOutputStream
Remember that web apps run on the server. NEVER on the client running the browser.
If you want to get a file to the end user, create it on the server, get a WebFile and force the download.
I just realized the OP asked again a question he had posted in https://forum.xojo.com/18319-opening-and-saving-files-on-web-app
Larry, can you explain more fully what you want to achieve ? Do you simply want to save data on the disk of the server (your PC), or on the user computer, or something else ?
I have a web app that will run on a users computer, not from a server. Using a web app removes a lot of compatibility issues for different users.
The app creates data and I want to be able to save it the users computer. This is all what I would call local processing, meaning there isn’t a server involved.
The standard file I/O functions don’t work on the web app since everything is designed to work through a server connection, which in this case we don’t have.
I can read files if they already exist on the users computer, but need to be able to write them out to local disk also. I had one suggestion that I would have to roll my own, but that doesn’t give me much help.
I am fairly new to XOJO having been a VB6 user for years. So some of the code is a little strange to me. Thanks for any assistance you can provide.
Strange how sometimes it is difficult to get through.
Have you read this post from last year ?
[quote=156311:@Michel Bujardet]Michel Bujardet Dec 31 Beta Testers, Xojo Pro
Just use the first example at http://documentation.xojo.com/index.php/TextOutputStream [/quote]
This works perfectly well. I just tested it again. It places a file called sample.txt in the computer Documents folder :
Dim Documents As FolderItem = SpecialFolder.Documents
If Documents <> Nil Then
Dim f As FolderItem = Documents.Child("Sample.txt")
If f <> Nil Then
//TextOutputStream.Create raises an IOException if it can't open the file for some reason.
Dim t As TextOutputStream = TextOutputStream.Create(f)
t.Write(ConvertEncoding("Hello World", Encodings.WindowsANSI))
t = Nil
Catch e As IOException
A lot of us come from VB6. Do not expect everything to be identical. When something does not work, try the examples in the documentation.
And if the examples do not work, then you ask and usually get a solution. But you need to try what is suggested.
Web App locally on Users Desktop? Sorry this sounds quite impossible? I guess you mixed up something. If you are using a regular PC for a xojo standalone web, then this PC is the server. it serves Web Apps on port 80 (most times) via HTTP/HTTPS protocol. This means that the Web App runs in the context of local user on this PC and do not know the anonymously connected users via Webbrowser. And so forth the Web App cannot save anything to their PC via SMB protocol for instance.
As said before with an Web App, you can let the user download it on his computer via browser. When using an xojo web app as standalone on an computer, then this computer who serves is “the server”.
I know from my former days of Win API programming with COM and DCOM Objects that Microsoft has something inventend what would match your demand. Shared COM Object classes over the local network. But heck it never was care-free. In fact it was hell with complicated proxy-stubs, marshalled data etc and it was kinda dropped later because of internet security reasons.
To help you anyway I suggest you to create a helper app running as service on the same PC with the web app. It scans a hotfolder or a database (just a place, where web app can place information what and where someting has to be copied). With this information the helper service can conduct all your copyfile stuff via SMB to any shared folders on your client PCs or even NAS devices.
@Larry Cluchey I don’t understand what you mean by textoutputstream not working on a web app. Have a look at this simple project which saves data from a text area to a text file in documents.
TextInputStream and TextOutputStream read and write files on the machine where the app itself runs. If that’s the same computer where the user is running their browser and the web app is running as the same user, you should have no trouble reading/writing to the users folders. If, however, the app is running as some other user, the app may not have permission to write into the user’s folders. If it’s running on a central server somewhere, the only files it has direct access to are those on the server.
To throw another monkey wrench in here, if users have mobile profiles under a windows domain, it would certainly be possible to access those directories from a central location as long as the app had enough permissions to do so, but that’s a little outside the scope of our forum.
I doubt this won’t work because web app runs in certain user context. Normally User A cannot access User B’s document folder and vice verca. And if a Web App Standalone is executed in context of Administrator none of the Users see any Document because its stored in Administrators’ document folder.
Even a terminal server solution won’t work because this would mean that each user had to start up its own web service. But there is only one port 80 existing.
[quote=156844:@Tomas Jakobs]I doubt this won’t work because web app runs in certain user context. Normally User A cannot access User B’s document folder and vice verca. And if a Web App Standalone is executed in context of Administrator none of the Users see any Document because its stored in Administrators’ document folder.
Even a terminal server solution won’t work because this would mean that each user had to start up its own web service. But there is only one port 80 existing.[/quote]
I bet an administrator could set up the ACLs so that the app would have permissions. I’ve seen it done with an app running as a Service, but it wasn’t pretty.
As far as I know mobile or server based profiles need an AD and DC. So there we have a server again. And sync between server-side and client side profile depends on given policies within windows domain. These things are mostly done only when logging in or loggin out.
Larry should take a minute and rethink his planings.
I can see how a standalone server hosted on a workstation of a local network could be of use. When I play on my Mac and use the PC, iPad or iPhone to access the app, I am probably doing that.
Without much precision from the OP, it is difficult to know what is the scope of what he wants to do, though.