FlexFTP (draft)
Wiadomo, że sockety ssą. Dotknęło mnie to właśnie przy pisaniu biblioteki FTP do Apollo. Póki co traktuję to bardziej jako pilot project, niż coś do używania. Na początku pomyślałem sobie, że najłatwiej będzie wzorować się na jakiejś jawowej implementacji. Jednak wszystko co znalazłem było... Jawowe. Znaczy obsługa socketu/bufora sprowadzała się zwykle do:
-
while ((bytesRead = input.read(buffer)) != -1)
-
{
-
output.write(buffer, 0, bytesRead);
-
}
-
output.flush();
co w przypadku flashowego modelu zdarzeń się nie sprawdzi.
Aktualnie wygląda to tak, że mamy klienta FTPClient i komendy FTPCommand i odpowiedzi serwera FTPResponse. Klient wysyła podstawowe zdarzenia FTPEvent.CONNECTED po podłączeniu, COMMAND po wysłaniu komendy i RESPONSE po otrzymaniu odpowiedzi. Na czas wysłania komendy, czy raczej serii operacji komenda-odpowiedź klient jest blokowany, żeby nie wbić się w kolejkę akcji. Wiadomo taki jest FTP. Wszystkie akcje powinny dziedziczyć po klasie FTPInvoker. Jej interfejs zapewnia początek wywołania execute(), obsługę odpowiedzi responseReceived() i sfinalizowanie bieżącej transakcji finalize().
Nie wykluczone, czy może na pewno ostatecznie wyglądać to będzie zupełnie inaczej. Bo już na dzień dzisiejszy nie podoba mi sie sposób tworzenia pasywnego połączenia i implementacja eftepowych akcji. Aktualnie klient podłącza się do serwera, listuje katalogi i zwraca ich zawartość jako tablicę obiektów FTPFile, ściąga pliki na lokalny dysk i wysyła. Z wysyłaniem wiadomo jak jest. Postępu poznać w stanie nie jesteśmy. Bo Adobe se odpuścił na socketach... Więc jeśli ktoś ma wolne łącze, lub wgrywa duuuży plik będzie sobie musiał poczekać na FTPEvent.UPLOAD.
FlexFTP - FTP pro Adobe Flex...
Pokud vyvíjíte internetové aplikace v Adobe Flex, možná se vám bude hodit knihovna FlexFTP , která, jak už jméno naznačuje, slouží k připojení a práci s FTP servery právě z prostředí Flex. Více informací na autorově blogu .
...
[...] Merci à Maliboo pour ce post. Au passage, le code est plus facile à lire que son blog..http://maliboo.pl/blog/2007/04/25/flexftp-apolloimpl/ [...]
Hello, I've a bug to report in FlexFTP. Can I right it here ? or maybe could have the maliboo e-mail ?
Thanks for this astoshishing lib.
Vincent
Hi,
please send it to maliboo@.. mail. Currently jobs are holded - I'm planning to re-write it to abstract somehow Socket::flush issues...
hmmm mam problem nie mogę tego w ogóle uruchomić :/
Could not resolve to a component implementation.
Jakiś pomysł?
Używam FlexBuildera 2.0.1 - SDK w wersji 2. Co mozna poradzić?
Z góry dzięki
Pozdrawiam
does anyone knows if there is any other information about this subject in other languages?
Hello mali, thx a lot, it works great.
However,
In the code of the UploadInvoker class, you send out dataChunks of 4096 every 300 ms.
Questions:
1) Is 300 ms (about 13KB/sec) standard / best practice, or a guessed magic number ?
2) Is there any way to get feedback about the arrival of the datachunks during large uploads (any event) ?
This could help to implement resume file upload and auto adjust upload speed (important).
Does ftp protocoll support this or do i have to pause / ask (getFile/directory) the host every 100(?) data packages manually and compare the file size already uploaded ?
David
@Dave:
1. No, it's just for testing purpose, because of:
2. There is NO feedback unfortunately:( See my comments:
http://www.onflex.org/ted/2007/05/flexftp-ftp-client-in-flex-using.php
and logged Flash Player bug:
https://bugs.adobe.com/jira/browse/SDK-12277
That's why I've hang this project for a moment. In future I've plan to resurrect this, probably on Cairngorm.
Mali,
I've been trying to build my own FTP client with AS3 in Flex 3 for AIR (now that it's no longer Apollo) purely for the learning experience. I'm new to socket programming but am interested in learning more about it. I've been looking at your source code for this project, some of which is over my head, in an effort to learn how to do some of this myself but I find myself stuck. I can make the connection but when I try to pass commands I get all sorts of weird and inconsistent behavior. Would you be willing to answer some questions about the proper way to do this? I'm sure any questions I have will be pretty simple for you.
[...] klasą Socket jest potężnym bólem pod kością ogonową. Tak jest między innymi z moim FlexFTP, jak również z mooskowym projektem ASql. Jednak jest szansa, że nas usłyszą. W Adobe Bug [...]
Na jakiej licencji udostępniony jest projekt?
@Wojtek: Na licencji "Bierzcie i robcie z tego wszyscy".
Hello Maliboo !
Congratulation for this great project !
I'm a newbie and i dont have this Class in Flex builder for testing your application :
import mx.rpc.soap.errors.ClientInputError;
(I eather don't have the package mx.rpc.soap.errors)
So what should i do ? Did i must install a particular library of Soap ?
In first thanks for your source.
I use FlexFtp in a Adobe Air project. I fix some errors but I have somes problems :
1. After 10 seconds the error : "Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: app:/FTPBis.swf cannot load data from :21. " occurred. This error appears randomly.
2. For somes files the error "Error #2030: End of file was encountered "
3. on IIS server the list of the folders in my servers is not correct. The name's field is empty and in the size's field is always at 0.
I hope you can help me to fix those problems.
PS : sorry for my bad english and it's not a problem if you want to speak French :D.
Nico
I fix (i hope) the errors "end of file" but not the error "sand box violation". I try to use a crossdomain.xml file but the error is still present. someone has an idea?
Hello Nico, i've got the same problems. how do fix the "end-of-file"-problem? I've simply added another eventlistener in the constructor of FTPClient.as to catch the "SecurityErrorEvent.SECURITY_ERROR" and "doing nothing with it". I know, this is more a workaround than a solution, but it works.
I have built a perfectly working ftp client in my application. However the sandbox security issue although i trap the error seems to be messing with my ftp server. I login and get a file and get the 226.. i wait for the Even.Close on the data transmission port and do other things, after about 10 seconds i get the message on 2048 and cant load data from the data transfer port. I thought i don't give a rip on the error but after this runs for 2 days it ftp's the server every 5 minutes during daylight hours then the ftp server begins to blow out. I check the netstat and the connections are being closed. so i'm thinking this error is somehow doing something. I have a program i wrote in visual basic 6 some time back and it ftp's this same server every 2 minutes and the ftp server NEVER messes up. vb ftp is via a ms control.. very easy to use. (hint hint adobe) I can't believe this hassle. I trying to do a very simple operation like this. FTP obviously cannot have any cross domain policies as it's not realistic as the ftp server could/should be anywhere and under someone else control.
BOOO!!
We are trying to avoid or workaround the Sandbox security dialog.
We got no success.
Any idea? We are using the same classes in a Flex3 app.