<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- cosFileTransfer Examples</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/cosFileTransfer-1.1.13.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>cosFileTransfer</strong><br><strong>User's Guide</strong><br><small>Version 1.1.13</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p> <ul class="flipMenu" imagepath="../../../../doc/js/flipmenu"> <li id="no" title="The cosFileTransfer Application" expanded="false">The cosFileTransfer Application<ul> <li><a href="ch_contents.html"> Top of chapter </a></li> <li title="Content Overview"><a href="ch_contents.html#id59850">Content Overview</a></li> <li title="Brief description of the User's Guide"><a href="ch_contents.html#id57519">Brief description of the User's Guide</a></li> </ul> </li> <li id="no" title="Introduction to cosFileTransfer" expanded="false">Introduction to cosFileTransfer<ul> <li><a href="ch_introduction.html"> Top of chapter </a></li> <li title="Overview"><a href="ch_introduction.html#id61147">Overview</a></li> </ul> </li> <li id="no" title="Installing cosFileTransfer" expanded="false">Installing cosFileTransfer<ul> <li><a href="ch_install.html"> Top of chapter </a></li> <li title="Installation Process "><a href="ch_install.html#id57197">Installation Process </a></li> </ul> </li> <li id="no" title="Using the File Transfer Service" expanded="false">Using the File Transfer Service<ul> <li><a href="ch_system.html"> Top of chapter </a></li> <li title="Overview"><a href="ch_system.html#id61189">Overview</a></li> </ul> </li> <li id="loadscrollpos" title="cosFileTransfer Examples" expanded="true">cosFileTransfer Examples<ul> <li><a href="ch_example.html"> Top of chapter </a></li> <li title="A tutorial on how to create a simple service"><a href="ch_example.html#id61854">A tutorial on how to create a simple service</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <h1>5 cosFileTransfer Examples</h1> <h3><a name="id61854">5.1 A tutorial on how to create a simple service</a></h3> <h4>Initiate the application</h4> <p>To use the complete cosFileTransfer application cosProperty must be installed.</p> <h4>How to run everything</h4> <p>Below is a short transcript on how to run cosFileTransfer. </p> <div class="example"><pre> %% Start Mnesia and Orber mnesia:delete_schema([node()]), mnesia:create_schema([node()]), orber:install([node()]), mnesia:start(), orber:start(), %% The File Transfer Service depends on the cosProperty %% application. Hence, we must install cosProperty first. %% It's NOT necessary to invoke cosProperty:install_db(). cosProperty:install(), %% Install File Transfer Service in the IFR. cosFileTransfer:install(), %% Now start the application and necessary services. cosFileTransfer:start(), %% Create two Virtual File Systems respectively representing an FTP- %% and the local NFS file system. VFSFTP = cosFileTransferApp:create_VFS('FTP', [], FTPHost, 21), VFSNATIVE = cosFileTransferApp: create_VFS({'NATIVE', 'cosFileTransferNATIVE_file'}, [], MyLocalHost, 0), %% Login to each system. {FSFTP, DirFTP} = 'CosFileTransfer_VirtualFileSystem': login(VFSFTP, "myId", "myPwd", "myAccount"), {FSNATIVE, DirNATIVE} = 'CosFileTransfer_VirtualFileSystem': login(VFSNATIVE, "myId", "myPwd", "myAccount"), %% If we want to copy a file from the NFS to the FTP we must first %% create a File object which contains its attributes. Target = 'CosFileTransfer_FileTransferSession':create_file(FSFTP, ["/", "ftp", "incoming", "targetFile"])), #'CosFileTransfer_FileWrapper'{the_file = Dir} = %% Lookup the file we want to copy. FileWrapper = 'CosFileTransfer_FileTransferSession':get_file(FSNATIVE, ["/", "home", "myId", "sourceFile"]), Source = FileWrapper#'CosFileTransfer_FileWrapper'.the_file, %% Now we are ready to transfer the file. Please note that we most %% call the source Session object. 'CosFileTransfer_FileTransferSession':transfer(FSNATIVE, Source, Target), </pre></div> </div> <div class="footer"> <hr> <p>Copyright © 2000-2012 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>