Export Callback anyone??
Frank Leahy
frank at backtalk.com
Tue Sep 20 15:41:18 EDT 2005
Kevin,
I would export locally, then upload the file via ftp.
Here's what I do:
local LUploadWorkDone, LCancelFTPUpload, LCurUploadUrl,
LCurUploadSize
put false into LUploadWorkDone
put false into LCancelFTPUpload -- set to true when/if user
clicks "Cancel" button in progress dialog
put toUrl into LCurUploadUrl
put theSize into LCurUploadSize
send "DoUploadStatusLoop toUrl, theSize" to this stack in 30
ticks -- timed "callback" which updates progress indicator
MyFTPUploadImage fromFile, toUrl, "DoUploadWorkFinish"
wait until (LUploadWorkDone <> false) with messages
on MyFTPUploadImage theImageFile, theUrl, theCallback
put "binfile:" & theImageFile into theBinFile
libUrlFtpUpload URL theBinFile, theUrl, theCallback
end MyFTPUploadImage
on DoUploadWorkFinish theUrl, theUrlStatus
put true into LUploadWorkDone -- breaks us out of the wait until ()
loop above
end DoUploadWorkFinish
on DoUploadStatusLoop toUrl, theSize
if LUploadWorkDone <> false or toUrl <> LCurUploadUrl or
LCancelFTPUpload = true then
exit DoUploadStatusLoop
else
set the cursor to busy
CheckForCancelFTPUpload -- looks to see if the user has clicked in
the "cancel" button
DoUpdateUploadProgress toUrl, theSize --
send "DoUploadStatusLoop toUrl, LCurUploadSize" to this stack in 30
ticks
end if
end DoUploadStatusLoop
on DoUpdateUploadProgress toUrl, theSize
put UrlStatus(toUrl) into theStatus
put item 1 of theStatus into theStatusStr
put 0 into bytesUploaded
switch (theStatusStr)
case "queued"
break
case "contacted"
break
case "connecting"
break
case "requested"
break
case "loading"
break
case "uploading"
put item 2 of theStatus into bytesUploaded
put item 3 of theStatus into bytesTotal
break
case "cached"
break
case "uploaded"
put theSize into bytesUploaded
break
case "error"
break
case "timeout"
break
case empty
-- could happen if we're saving to disk instead of uploading
put theSize into bytesUploaded
break
default
answer error "Error: invalid url status '" & theStatusStr & "'"
with "OK" titled getPhotoAlbumDialogName()
end switch
put trunc((LFTPBytesUploaded + bytesUploaded) / LFTPUploadTotalBytes
* 100) into thePercentage
put FormatSizeAsText(LFTPUploadTotalBytes) & ": " & thePercentage &
"% (" & \
(LFTPBytesUploaded + bytesUploaded) & "/" & LFTPUploadTotalBytes
& ")" into ftpMsg1
UpdateFTPProgressBar ftpMsg1, "", "", " Status: " & theStatusStr,
thePercentage
end DoUpdateUploadProgress
On Sep 20, 2005, at 8:08 AM, use-revolution-request at lists.runrev.com
wrote:
> From: <kevin at stallibrass.com>
> Subject: Export Callback anyone??
> To: <use-revolution at lists.runrev.com>
> Message-ID: <20050920150046.64497824DA4 at mail.runrev.com>
> Content-Type: text/plain; charset="us-ascii"
>
> I'm using
> export image "image1" to URL
> "ftp://user:passwordr@ftp.mysite.com/image1.gif" as GIF
> to replace an existing image on a web page. Sometimes, this works but
> mostly
> it fails,
> replacing the existing file with an empty one i.e. 0kb
>
More information about the use-livecode
mailing list