Send Folder to Website?

I need to upload a folder to a url. Im not finding much information on how to do this with Xojo Desktop on Windows or Macintosh. Can anyone share code on how to upload a folder to a url? The folder can be zipped to make it easier. I just need a method to upload. TIA.

Is the url expecting an upload? Is there an api? Are you using ftp? Not sure where to start here.

2 Likes

The url is Xojo Cloud in my web home application for the company. As far as I know, the documents folder in the application can receive data. That’s where I was told to put things because it’s the folder that is available to share with. I have the url for the documents folder. There is not an api. I would like to use url connection to send the file to the website, not ftp.

You should probably put code in HandleURL of your web app to receive a file upload and store it in the documents folder. Your desktop app can use URLConnection to send the file to the web app. Basically create your own api.

1 Like

Any idea of what that code would look like? Anyone doing this?

Long ago we worked together on a SEO project while I worked at BKeeney Software. If you’d like private one-on-one consultation again, you are welcome to reach out to me privately either here or through email <support@strawberrysw.com>

Still looking for help if anyone has code that would go into the handleURL event on my web app to put uploads into the documents folder. The url is home.schoolaccounting.com/Documents. It will be receiving a zipped file from our desktop app using URLConnection. Thanks

I’m going to tell you right now that this is not an easy lift. It’s certainly possible, but handleurl is going to try to load the entire object into memory. If the file is small, that’s not going to be a problem. If it’s big, the app is going to try to load that all into a string, which you’re going to have to decode, so you’re going to actually have two copies in memory.

The webfileuploader already handles all of the idiosyncrasies for you and provides you with a folderitem that you can just copy.

1 Like

I really don’t want the app to do anything with it at all. The app is just our website but written in Xojo Web. I don’t want the app to do anything with it. I just want a customer to be able to send us a zipped file with databases in it. Then from our office, we can go into that folder using an ftp program and download to our computer to troubleshoot something in their database. I don’t want the app for the website to do anything with it. Basically I just want to use the storage on our cloud to store the file so I can remotely access it using an FTP program. Does that make it any easier?

To be clear, you can’t just post file into a website. The server has to be part of the handling process. The browser will copy with uploading and placing the file into a temporary folder, the website / app has to deal with it from then on.

If your app is a Xojo Web app running on Xojo Cloud, why can’t you just add a File Uploader control to a dedicated “upload” page? It should work fine if the user zips the folder. The uploader will just receive the single zipped file. You should be able to remote in and download it.

1 Like

Well a lot of our customers are older school clerks who would have a hard time navigating on their computer to select the upload file and then upload it. It’s for that reason that we just used FTP in the past to upload it. We are trying to get away from plugins so I was trying to just upload by url.

I don’t recommend doing what you might want to do.

If I were you, I would prioritize the security of XOJO Cloud and NEVER store files there.

Unless you upload them to the database using the application developed in XOJO.

For this goal, it’s better to use Google Drive. Invite all users who need to store their data.

I would recommend you stick with FTP unless you want to build your own secure API, which sounds like a lot of work to get right.

Ok, so I did this recently for another client and I’m going to describe the process since I can’t give away their code…

We made a highly customized WebSDK file uploader control (it’s possible to replace the uploader UI and the engine thankfully) and made it so files could be uploaded to an AWS S3 bucket directly using a presigned url. This lets the app help the user through the process of selecting the file(s) (in this case through a drag and drop process) and then triggers one or more simultaneous uploads, whose progress is reflected in the app.

The process goes more or less like this:

  1. The user selects one or more files and drags them to a designated drop area on the page.
  2. The control transmits file info for each file to the server and assigns each one an upload engine.
  3. The server contacts AWS through the AWS cli and generates a presigned upload url for each file.
  4. The server sends the upload UI to the browser.
  5. The server returns the url for each file/engine combo back to the browser.
  6. The browser makes a PUT request to each url for the corresponding files.
  7. While sending each file, the prowler send progress & error info to the server.
  8. The server sends progress UI updates back to the browser.

My point is that this is all possible within Xojo, and they did add some things last spring to make it easier, but you’re going to need to know some other underlying technologies to make it work. Browsers themselves don’t know anything about FTP or SFTP. those are just protocols that are handled by other apps and wouldn’t expect an app to be able to handle them except in the download direction anyway. You could however make your own protocol and use a helper app that understands the protocol. A URL like this could be used for instance, passing any parameters that you need as part of the URL.

myupload://upload/url?file=url_encoded_file_path

Then your helper picks it up when you do GoToURL and does the upload for you.

Be very careful. You don’t want to put any credentials that are part of your Xojo account into a url or burned into the uploader or you risk someone else getting access to or corrupting your app.

1 Like

Thank you for the response. After seeing all this it sounds like I need to either just stick with an ftp plugin for uploading to make it easier or upload to Google Drive or something like that. I don’t want all those moving parts. Maybe Xojo will get around to adding in ftp at some point. Thanks for your help.

It seems highly unlikely, ftp is pretty ancient. There is already a control in Xojo web for uploading a file directly from a web browser. The user would need to zip the folder and add it to the control. The rest is handled by your Web app.

1 Like

I have to agree. Not only is it ancient but oh so insecure. Kinda like connecting to a website with http instead of https, anyone could listen in and grab the transferred files. The best you could hope for is a way to dynamically add SFTP users that only had access to a certain folder and remove them when the upload was complete, but that would be highly specific and Xojo would need to be very careful with the implementation to prevent data loss or hacker access.

How big are these files anyway?

What about ftps?
I haven’t followed network technologies progress recently, but it looks to me like ftp has its use and shouldn’t disappear completely.

ftps is slightly better than sftp as the later only encrypts the file transfer port and ftps does both. When ftps solves the encryption element of the program it still requires the server to be protected as well as the client.

FTP is unlikely to go anywhere soon as it’s commonly used for uploading websites, as clients can copy with the opening, closing, identifying transfer types, new folders etc. A lot of operating system don’t come with FTP clients these days. Apple dropped the command line version from macOS, for example, due to security worries. Equally, windows never really had one to begin wth.

Your average use wouldn’t know were to start with “normal” FTP commands. Especially, the requirement to change transfer types for binary and text files. Sure there are GUI clients out there that auto configure for common file types and support drag and drop transfers, but the addressing of the servers has to be learned as well as the folder structure of the server. A simply web based upload control is far easier for most users to cope with.

That said it’s unlikely to become a thing build into Xojo, it’s a none trivial protocol in a few ways with command and transfer ports to worry about. I do seem to remember a library being available back in the day, I can’t remember where though, or if it’s even maintained.