{"id":243,"date":"2010-08-18T13:45:58","date_gmt":"2010-08-18T11:45:58","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=243"},"modified":"2011-02-11T15:46:57","modified_gmt":"2011-02-11T13:46:57","slug":"flex-ftp-make-directory","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2010\/08\/18\/flex-ftp-make-directory\/","title":{"rendered":"Flex FTP Make Directory"},"content":{"rendered":"<p>I&#8217;m messing around with <a href=\"http:\/\/maliboo.pl\/projects\/FlexFTP\/\" target=\"_blank\">Flex FTP<\/a> at the moment and found that there is no way yet to create a directory on the FTP server. I had a quick look through the code on how the other FTP actions were implemented. Being surprised with the nice setup of the code I had quite easily added the &#8220;make directory&#8221; action and got it working properly. You can download my MakeDirInv class here: <a href=\"http:\/\/ansuz.nl\/toys\/randomcode\/MakeDirInv.as\" target=\"_blank\">http:\/\/ansuz.nl\/toys\/randomcode\/MakeDirInv.as<\/a><br \/>\nAll you need to do after that is patch the FTPClient class by adding the following method.<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/**<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">* Creates a directory on the remote host.<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">*<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">* @param newDirName The name of the new directory to create.<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">* @param parentDir (Optional) The directory to create the new directory in.<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">*\/<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0066CC\">public<\/span> <span style=\"color: #000000;font-weight: bold\">function<\/span> makeDir<span style=\"color: #66cc66\">&#040;<\/span>newDirName:<span style=\"color: #0066CC\">String<\/span>, parentDir:<span style=\"color: #0066CC\">String<\/span> = <span style=\"color: #ff0000\">&quot;\/&quot;<\/span><span style=\"color: #66cc66\">&#041;<\/span>:<span style=\"color: #0066CC\">void<\/span> <span style=\"color: #66cc66\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0066CC\">trace<\/span><span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #ff0000\">&quot;FTPClient.makeDir(newDirName, parentDir)&quot;<\/span><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">invoke<span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #000000;font-weight: bold\">new<\/span> MakeDirInv<span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #0066CC\">this<\/span>, newDirName, parentDir<span style=\"color: #66cc66\">&#041;<\/span><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #66cc66\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Once you&#8217;ve done that, you&#8217;re ready to create directories on the FTP server you&#8217;re connected to, see the example below.<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">ftpClient.<span style=\"color: #006600\">addEventListener<\/span><span style=\"color: #66cc66\">&#040;<\/span>FTPEvent.<span style=\"color: #006600\">CREATE_DIR<\/span>, dirCreatedHandler<span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">ftpClient.<span style=\"color: #006600\">makeDir<\/span><span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #ff0000\">&quot;myNewDir&quot;<\/span>, <span style=\"color: #ff0000\">&quot;\/someSubDir\/&quot;<\/span><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p><em>PS: This isn&#8217;t fully tested yet, so do let me know if you find some bugs.<\/em><\/p>\n<p>Links<\/p>\n<ul>\n<li><a href=\"http:\/\/maliboo.pl\/projects\/FlexFTP\/\" target=\"_blank\">Flex FTP<\/a><\/li>\n<li><a href=\"http:\/\/ansuz.nl\/toys\/randomcode\/MakeDirInv.as\" target=\"_blank\">MakeDirInv class<\/a><\/li>\n<\/ul>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>I&#8217;m messing around with Flex FTP at the moment and found that there is no way yet to create a directory on the FTP server. I had a quick look through the code on how the other FTP actions were &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2010\/08\/18\/flex-ftp-make-directory\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,93,65],"tags":[143,97,99,98],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-actionscript-30","category-air","category-flex","tag-flex","tag-flex-ftp","tag-flexftp","tag-ftp"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":4,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":270,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/243\/revisions\/270"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}