Page 1 of 1

Upload Video per FTP

Posted: Fri Jan 18, 2013 8:08 pm
by csoca
Hi,

I am trying to upload a video to a ftp-server. Uploading an image is no problem. With the code below I also can upload a file, but not the video. The content of the file is only the path, if I open the file with an editor.
For pick the video I have an external av from mergext
the problem is the line: put tFileForUpload into URL theURL - only the filepath is in the uploaded file
here I need binary files ? but how to "convert"?

thanks for help
Chris


Code: ***********************************************
on touchEnd pId
mobGUIUntouch the long id of me

local tFileForUpload, tFileName
put mergAVPick("library","medium",180) into tFileForUpload
set the itemdel to "/"
put "ftp://user:pwd@ftpserver/myvideo1.mov" into theURL

put tFileForUpload into URL theURL !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


if the result is not empty then
answer the result
hide group "progress"
end if

end touchEnd

Re: Upload Video per FTP

Posted: Fri Jan 18, 2013 8:18 pm
by csoca
Hi,
I found a first solution:

I replace: put tFileForUpload into URL theURL

to:
put tFileForUpload into theFilePath
open file theFilepath for binary read
read from file theFilePath until end
put it into theBinaryData
close file theFilePath
put theBinaryData into URL theURL

the other question: is this solution good for large files 30-70 MB?
thanks
Chris

Re: Upload Video per FTP

Posted: Mon Jan 21, 2013 10:41 am
by shaosean
You would be better off doing a loop over the data and upload it in chunks so as not to tie up your GUI (remember Rev is single threaded).. By doing the "read until EOF" you are loading the whole file in to memory first and then sending it.. When doing your loop, do not use a repeat structure, but a recursive send loop..

Re: Upload Video per FTP

Posted: Wed Jan 23, 2013 3:27 pm
by csoca
thanks for your answer and suggestion. :D
Do you have a short code example or link to one of a "recursive send loop"?