Sample stack and lc server scripts for uploads to lc server

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Sample stack and lc server scripts for uploads to lc server

Post by matthiasr » Mon Jun 12, 2017 12:01 am

Hi,

i´ve created a little stack and two livecode server scripts that allow to upload a file to a web server running livecode server version 8 or higher.
After successful upload the download url of the uploaded file is copied to the clipboard for sharing purposes. The stack has a little filemanager included which allows to get the d/l url for older uploaded files and it allows also to delete older files which are not needed anymore

The stack uses Bernd Niggeman´s Gauge widget for showing the upload progress. See his post about this really cool widget http://forums.livecode.com/viewtopic.ph ... ge#p154776

Image Image


There are only minimal adjustments needed in the stack script of the livecode stack to get it running with your web server.

The archive contains the livecode stack, 2 livecode server scripts, the .lcb file for the Gauge widget, an installation guide for the Widget and a readme file.

I´ve tested it with Livecode 8.1.4 and Livecode server 8.1.2.

Please read the file PLEASE Read Me First!.txt first.

Hope it´s of some use for the one or the other


Unfortunately the zip archive is 452kb in size and the forum does only allow attachments with a size up to 256kb.
Therefore please find the archive here http://dl.qck.nu/?dl=DropUpload.zip


Matthias
Last edited by matthiasr on Mon Jun 12, 2017 4:51 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Sample stack and lc server scripts for uploads to lc ser

Post by FourthWorld » Mon Jun 12, 2017 1:18 am

Super cool. Thanks for posting that.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Sample stack and lc server scripts for uploads to lc ser

Post by matthiasr » Mon Jun 19, 2017 3:01 pm

As the stack only runs with LC 8.1.4, because of the widget, i decided to make some changes to the stack, so it can be used either with the widget (LC 8.1.4) or with a scrollbar (any LC8 or 9).

If you want to use the stack with a scrollbar instead of the widget, then just delete the gauge widget on the card "main" and run the following command in the message bo

dispatch "setupProgressObject" to stack "DropUpload" This makes the scrollbar and a background image visible.

If you later decide to use the widget instead of the scrollbar, just add the gauge widget to the stack (don´t care about position or size) , make sure its name is "gauge" and run the above command again.
This then hides the scrollbar and the background image and moves the widget into its correct position and makes also some changes to the widget (size and display options).

The link is still the same:
https://dl.qck.nu/?dl=DropUpload.zip


Matthias

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

Re: Sample stack and lc server scripts for uploads to lc server

Post by keithglong » Mon Dec 18, 2017 12:56 am

Hello,

This is a really great example; thanks for sharing. I am only just beginning to experiment with the tsNet capabilities myself. By the way... Is there a way to cancel uploads while in progress? I see "tsNetClose" and "tsNetCloseConn" in the dictionary, but I'm not having much success playing with them.

Thanks!

- Boo
Gulf Breeze, Florida

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

Re: Sample stack and lc server scripts for uploads to lc server

Post by keithglong » Mon Dec 18, 2017 9:14 am

Hi Again,

Okay; you can use tsNetPost to upload asynchronously and cancel the upload with tsNetCloseConn and a custom connection ID.

In Matthias' code, you can use:

Code: Select all

get tsNetPost(pConnectionID, tURL, pHeaders, line 2 to -1 of sFormData, pCallback, pSettings)
I also got it working with a progress bar utilizing a send handler to update the progress accordingly...

Cool stuff. (And still playing around with it.)

Cheers,

- Boo
Gulf Breeze, Florida

Post Reply

Return to “Talking LiveCode”