Uploading a text file to a server/URL

Before we start this: I have zero knowledge of webprogramming whatsoever. Sounds like this is going to be fun? Great! :stuck_out_tongue: Ok but honestly: I don’t know how complicated my question really is and whether it is to much to ask on a forum like this, so be prepared, I guess? :sweat_smile:
I am in the process of writing a programm that outputs a .txt file and uploads it to a location on the internet. This file should be read by another programm which then displays the information in the wanted format. I have done everything to prepare for step 2 (step 1 and 3 completed). Both programms are written in Processing - the first in Java mode, the second one in android mode. I don’t know anything about P5.js or javaScript in general, but would be willing to get into that if necessary and given the right instructions.
What I believe to know:

  1. I will need to rent/buy a domain or something that allows me to create a URL linked to a .txt file which can be manipulated my Processing
  2. Processing is probably not the best place to do this in lol

Okay, so to summarize my problem:
I need to know how to upload/edit an existing text file somewhere on the internet. Preferably a place that can be used by loadStrings(URL);.

I am thankful for any kind of answer!

What you’re talking about I think would be best accomplished by server side programming. There’s this idea of an api that’s kind of hard to explain. I would suggest checking out Dan Shiffman’s video series on the topic. It mostly about working with node.js and p5.js but I think a lot of it could be applied to a setup with Processing.

if you make the file locally you could try upload it with FTP,
search for “processing FTP upload”
( i never play with that )

Thanks @figraham ! I’m halfway into watching everything right now, however I am a little bit concerned about node.js. You see, the programm that outputs the file is not going to be run by me. The whole point of it is to create a GUI or something for the one person that will use it daily. That person doesn’t know anything about programming in general. (And while we’re at it: The programm that receives the data is going to be run on many mobile devices.) So thank you, but I don’t know if this is going to help me sadly.

@kll Thanks! I found this entry on the previous forum from 5 years ago. Do you think it still works?

hm, probably not out of the box,
other idea, the computer what makes the file runs
google drive
processing writes the file to disk / path of that google drive mapping
( the google drive program loads it to the online google drive ( to a public folder ))

the app loads from that public folder.

@kll Haha, forgot to include the link: https://forum.processing.org/two/discussion/7124/text-to-ftp-server :sweat_smile:
Anyways I played around with ftp, but I can’t even get examples to work, so… yeah. I have no experience with google drive but it’s definetly worth looking into. Could you help me a little bit with that, please?

sorry, looks that also google drive not give a simple file read,


no idea how to auto download use API?

from my server it works, so FTP upload would be a way if possible.

String filename = "data/public_file.txt";
String googledrivefile = "https://drive.google.com/open?id=1_iyPfxrSo6UJPTQJW1ODElfMFptrB-27";  // does not work
String onlinefile = "http://kll.engineering-news.org/kllfusion01/downloads/public_file.txt";

String[] lines, onlinelines;

void setup(){
//  lines = loadStrings(filename);
//  printArray(lines);
  println(" now load the online version! ");
  onlinelines = loadStrings(onlinefile);

bad luck,
same test with a free account at byet.host got error.
the file show at browser, but when called from processing,
server say like:
" your browser need java script enabled…"

That’s unfortunate. Gotta keep on searching then…

I’ve also posted this on Stack Overflow now.

@kll I’ll try to understand FTP. Just out of interest, what kind of server do you have and how did you get the file on there?

for my BLOG i use a
server ( and domain name ) via a well known provider
( but i got it sponsored from friends i help out with code and electric calculations… )
i still do have ( like also for backup and tests ) a free webspace what works well for many years.
both come with one FTP account for file upload, like for installation of a CMS.

now there are many FTP software / but for windows i use a plugin into a free file manager
( what can do 2 windows, so like take a snapshot from my desktop, copy via FTP to server and include the picture in my blog is as easy as here from the forum upload software )

so making a file by processing and use a FTP file manager is ok,
but for your case, where anyhow link and filename … all stays same,
a FTP client you can call by a batch file ( .bat / .sh ) could be much better,
and possibly even spawned from processing.

I moved this to p5.js, as that appears to be the question category.

I just want to point out that, while this is a good question which leads to good answers, it is possible that this is not what you want to do. Is there one uploader and many downloaders, or is this one-to-one? Does the uploading / downloading happen syncronously, or asynchronously? Depending on what you are trying to accomplish you may actually just want to transfer a text string using a direct protocol, and just skip the file and the server entirely. Can you say more about what you are trying to do, specifically?

I haven’t read all the posts so I apologize if my answer overlook any other detail. As Jeremy pointed out, your application requirements needs to be defined upfront. I would like to add that if your intention is to write data to a server and read it from another application and the frequency is low, say once every few seconds, then a simple server app will work for you. Here you will be tempted to write your application in any available server languages (php, node, go, java, ruby, .NET, python, etc).

You could use loadString() to read directly from the server and you can even use the same function to write to the server if you use a GET request in the process. You need to handle these request on the server side.

Note that you do not need to buy a domain or pay for hosting services. For developing/testing, you can find many free solutions. One that comes to mind is atspace. I could recommend to use one of the cloud providers. I have a preference for GCP. You can use the free tier (always free) app engine solution. GCP makes it really easy to do this stuff. Either way, you need to become familiar with HTTP requests and how to handle them.

For GCP, you need to install the Cloud SDK in your computer. Then search “App Engine [LANGUAGE] standard quickstart” and you will be on your way to deploy. By the way, with GCP, you will need to create an account in GCP and you will need a credit card. If you use the free tier, you will not get charged. I can provide additional details if you decide to go this route. Atspace would not require a credit card. You will need to ftp your application to the server and tweak it to get it working.


Thank you both for your answers. Okay so for my program…
First of all, it consists of two parts: the one we’re talking about on PC, and the other one for mobile devices which won’t be downloaded more than 1000 times. So what is this seemingly useless app? I’m still going to school and whenever there is a teacher who can’t be there, this is shown on the “Vertretungsplan”, or “cover-plan”, in English? Basically, whenever we are in a different room than usual or our teacher had to be exchanged, we can see this on that plan/board/whatever.
We - the students - have been asking for an app that shows ous that plan on our phones, so I decided to handle that problem myself (I only wanted to see if I could program it, but now it seems like it could actually be published). So the app only uses loadStrings(URL); once in setup (I guess around 300 people would actually use it in the morning and while preparing for school in the evening).

But how do the teachers set up that plan?
This is the program we’re talking about: it basically compresses all the steps that are too uncomfortable for a non-programmer into one button press. This function would be calles once or twice a day.

Okay so before anyone here feels cheated, I have already solved the uploading process. I explain it here However I would be interested in learning how to use the commons net library with ftp in java/processing. So maybe we could continue this discussion under a more fitting name and switch to this topic.

Or, if you don’t want to help me anymore since I already solved it, that’s fine too.

From what I understand, you are using ftp to move the data to a hosting service so other people can access it. While this works, a much better approach is to use a REST API. You can submit/retrieve data using POST/GET. Using FTP works, but you are using the local system (local resources) to send the data to the server. This could work easily in your development environment, but it could become a challenge using other environments. For instnace, your teachers could be using mac, Windows or less likely, Linux. Would they have access to the FTP to send data? Would they consent to use FTP to send data?

Using Rest API would work better in your application. Most languages will offer a library that allow you to do HTTP request so you just need to design what data to transfer and how to store it in the server. Then you need to decide what commands to use to download the data and present it to the application, and then the application use this data to present it to your other users: the students.

Two posts that could be relevant to your case:

  1. https://forum.processing.org/two/discussion/25982/how-do-i-get-a-snippet-of-text-scraped-from-http-request-to-go-into-a-rolling-banner#latest
  2. https://forum.processing.org/two/discussion/20341/emotion-api-and-post-and-http-requests-library#latest

I strongly suggest you continue to work in your project as it is. Work in the concept and don’t focus too much in the details. After you have a minimum demo, give it a try with a group of your friends and collect their input. In this journey also check Rest API solutions and how it could be used in your system. If you want to have a feeling about what a Rest API could do, explore Dan Shiffman’s channel. You won’t find a way to implement it in your code but it should give you an idea of how that technology is used.



Thank you for your answer! I’ll look into that.