Discussion:
[Ur] Reading files uploaded by a user
Simon Van Casteren
2018-08-11 20:34:28 UTC
Permalink
Hey everybody,

Does anybody have experience with reading files uploaded by a user in
Ur/Web? My use case: I'm building an application used by (music) schools
and migrating their data into my database is a big thing. Medium-sized
schools often have more than 1000 students following classes, so adding
them one by one via an online form is a big time investment, especially
since students don't just have names but also addresses, phone numbers,
email addresses and pre-existing enrollments.

I want to provide import functionality of this data and I feel CSV files
are probably the best way to go with this. Microsoft Excel exports these,
database programs can export these they're human-readable, etc.

I know Ur/Web supports file upload with the file and blob types, but I
don't know where to go from there. Probably I'll have to use the C FFI to
then read these files, but I honestly don't know where to begin. I don't
know what the internal representation of these types is, nor would I know
where to begin searching how to then process these into Ur/Web data
structures.

Ideally I would have a function that just does:

blob -> transaction (list string)

or something, maybe providing an encoding if needed. I really don't know
where to begin here, so any help is much appreciated!

BTW: Thanks for Ur/Web, it's been a godsend for me.

Simon
Adam Chlipala
2018-08-11 20:53:06 UTC
Permalink
Post by Simon Van Casteren
I want to provide import functionality of this data and I feel CSV
files are probably the best way to go with this. Microsoft Excel
exports these, database programs can export these they're
human-readable, etc.
I know Ur/Web supports file upload with the file and blob types, but I
don't know where to go from there.
I just use textboxes for CSV upload, in a few different production
deployments based on UPO <http://upo.csail.mit.edu/>.  I have to admit,
it isn't obvious that there shouldn't be a [blob -> string] function in
the standard library, so I'd be open to adding that, too, if it sounds
like the demand is there.
Post by Simon Van Casteren
BTW: Thanks for Ur/Web, it's been a godsend for me.
Glad to hear you're getting some mileage out of it!  I'm sure the crowd
here will be interested to hear more details of your applications, when
they're far enough along (and I like to add links from the Ur project site).
Simon Van Casteren
2018-08-12 09:33:25 UTC
Permalink
Using textboxes is indeed a good idea. I think with some help text, it
should be no problem for my users to understand how to use this.

That CSV.parse function is really good for inspiration. I'll probably
change it a bit so I can provide parsing and validation functions per field
so I can give a bit more feedback to users when parsing fails, but it's so
nice to have something to start with. I need to look some more into the UPO
repo, it's some very nice code.

I'll definitely be writing up some stuff about my experience with Ur/Web
once the development calms down and my first clients run stable, but that
might take a while. My whole application is in Dutch at the moment, but I'm
definitely planning to translate it to English as well. It will all come,
but will take some more time :).

Simon
Post by Simon Van Casteren
I want to provide import functionality of this data and I feel CSV files
are probably the best way to go with this. Microsoft Excel exports these,
database programs can export these they're human-readable, etc.
I know Ur/Web supports file upload with the file and blob types, but I
don't know where to go from there.
I just use textboxes for CSV upload, in a few different production
deployments based on UPO <http://upo.csail.mit.edu/>. I have to admit,
it isn't obvious that there shouldn't be a [blob -> string] function in the
standard library, so I'd be open to adding that, too, if it sounds like the
demand is there.
BTW: Thanks for Ur/Web, it's been a godsend for me.
Glad to hear you're getting some mileage out of it! I'm sure the crowd
here will be interested to hear more details of your applications, when
they're far enough along (and I like to add links from the Ur project site).
_______________________________________________
Ur mailing list
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Loading...