守望者--AIR技术交流

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: ANE FlasCC 炼金术
查看: 2208|回复: 0

微型http服务器与文件管理功能ANE(IOS)

[复制链接]
  • TA的每日心情
    擦汗
    2018-4-10 15:18
  • 签到天数: 447 天

    [LV.9]以坛为家II

    1742

    主题

    2094

    帖子

    13万

    积分

    超级版主

    Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

    威望
    562
    贡献
    29
    金币
    52619
    钢镚
    1422

    开源英雄守望者

    发表于 2015-2-2 16:48:26 | 显示全部楼层 |阅读模式
    应用下载
    应用名称: ANEFileSyncInterface
    支持64位:
    当前版本: 未知
    运行平台: IOS 
    开发语言: ActionScript 3 其他 
    应用类别: ANE-C/C++
    应用简介: A micro http server with FileManagement capabilities Native Extension
    本帖最后由 破晓 于 2015-2-2 16:51 编辑

    ANEFileSync
    A micro http server with FileManagement capabilities. Based in the CocoaHTTPServer library.https://github.com/robbiehanson/CocoaHTTPServer
    It lets you to:
    • serve static web pages
    • upload files to the device via POST
    • actions to rename, delete, create dirs and list dir contents
    • list directory contents
    Usage
    Include the ANEFileSync.ane to your project.(Get it inside the NATIVE/ANEFileSyncInterface/PRODUCTSdir ). Current ANE provides Device & Simulator support.
    There is a known bug in the simulator that prevents to upload files,so the application quits unexpectedly.
    Avaliable Class Methods
    1. isSupported() : Boolean;
    复制代码

    Returns if the native extension is supported or not
    1. dispose() : void;
    复制代码

    Disposes the extension
    1. getDirectoryListingEnabled() : Boolean;
    复制代码

    Returns the state of the
    1. getDocumentRoot() : File;
    复制代码

    Returns the actual DocumentRoot File
    1. getEnabledActions() : String;
    复制代码

    Returns a comma separated string of the active actions
    1. getInterface() : String;
    复制代码

    Returns the current device ip.When no connection is avalible it will return 0.0.0.0Also when running in simulator it will return 0.0.0.0 but you can access it locating your current machine ip
    1. getModificationDateFormat() : String;
    复制代码

    Returns the current date format.
    1. getPort() : uint;
    复制代码

    Returns the current listening port
    1. getUploadDir() : File;
    复制代码

    Returns the actual Upload dir
    1. getUploadDirectoryListingEnabled() : Boolean;
    复制代码

    Returns true if the actual upload dir is browseable otherwise returns false
    1. setDirectoryListingEnabled(enabled : Boolean) : void;
    复制代码

    When enabled, if the current directory has no index.html file shows a directory listing
    1. setDocumentRoot(directory : File) : void;
    复制代码

    Sets the current webserver root directory
    1. setEnabledActions(actions : String) : void;
    复制代码

    Comma separated string to set the avaliable server actions.By default all avaliable actions are enabled.Avaliable actions are:* createDir* delete* rename* listDir* uploade.g: setEnabledActions('createDir,delete');
    1. setModificationDateFormat(format : String) : void;
    复制代码

    Sets the current modification date format.The default format is yyyy/MM/dd HH:mm
    1. setPort(port : uint) : void;
    复制代码

    Sets the current listening port
    1. setUploadDir(uploadDir : File) : void;
    复制代码

    Sets the current webserver upload directoryThe upload dir can be inside or outside the webserver root directory
    1. setUploadDirectoryListingEnabled(enabled : Boolean) : void;
    复制代码

    Lets you hide/show the upload directory when it is inside the webserver root and directory listing is enabled
    1. start() : Boolean;
    复制代码

    Starts the server.Returns true on success otherwise returns false
    1. stop() : void;
    复制代码

    Stops the server
    Avaliable Class Events
    ANEFileSyncEvent.FILE_UPLOADED
        Dispatched when a file upload is completed
        event.data.filename
         contains the name of the uploaded file
        event.data.path
             contains the native path to the uploaded file
    ANEFileSyncEvent.FILE_DELETED
        Dispatched when a file has been deleted
        event.data.result
       contains true if the file has been correctly deleted otherwise contains false
        event.data.path
         contains the native path to the deleted file
    ANEFileSyncEvent.FILE_RENAMED
        Dispatched when a file has been renamed
        event.data.from
         contains the original renamed file path
        event.data.to
           contains the final renamed file path
        event.data.result
       contains true if the file has been correctly renamed otherwise contains false
    ANEFileSyncEvent.DIRECTORY_CREATED
        Dispatched when a directory has been created
        event.data.result
       contains true if the directory has been correctly created otherwise contains false
        event.data.path
         contains the native path to the created directory
    ANEFileSyncEvent.SERVER_STARTED
        Dispatched when the server starts
        event.data.ip
           contains the server current ip. ( 0.0.0.0 in Simulator )
        event.data.port
         contains the server current port
    ANEFileSyncEvent.SERVER_STOPED
        Dispatched when the server stops
    Minimal contens of DocumentRoot directory
    You must include a directory named ___templates___.
    Inside this directory you must provide a file named 404.html that will show generic server errors.
    Also if you set DirectoryListingEnabled you must provide a file named dir.html that will be used to show the default Directory Listing
    dir.html templating
    dir.html uses mustache templating system to render his contents.
    The current avaliable properties passed to the template are:

    1. {{parent}} The parent dir path
    2.     {{files}} Array containing the current directory files

    3.     Use this minimal template to access each file properties:

    4.     {{#files}}
    5.         {{type}} // can be file or dir
    6.         {{path}} // full file path
    7.         {{name}} // file name
    8.         {{size}} // file size in bytes
    9.         {{modification}} // modification date
    10.     {{/files}}
    复制代码
    Basic Document root example is located at BasicDocumentRoot directoryAlso you can find a working example of DocumentRoot inside the provided example/bundle dir
    Client side javascript methods to interact with the server
    A little javascript library to interact with the server actions.To use it include the IOSFileSync.js to your page.

    All the paths used must be relative to the DocumentsRoot or UploadDir

    The library uses the promise approach to interact with IOSFileSync methods, so you can use it as:
    1. IOSFileSync.methodXXX().then( success, fail, progress /* only 4 upload */ );
    复制代码
    Avaliable javascript methodsIOSFileSync.rename
    1. IOSFileSync.rename( from , to ).then( success, fail );
    复制代码
    IOSFileSync.deleteFile

    1. IOSFileSync.deleteFile( file ).then( success, fail );
    复制代码
    IOSFileSync.createDir

    1. IOSFileSync.createDir( dir ).then( success, fail );
    复制代码
    IOSFileSync.listDir

    1. var success = function( data )
    2.     {
    3.         // data will contain an array of file objects
    4.        /*
    5.            [
    6.                 {
    7.                     path:'full file path',
    8.                     name:'filename',
    9.                     isDir:'true if file is a directory',
    10.                     size:'the file size in bytes'
    11.                 },...
    12.            ]
    13.        */
    14.     }
    15.     var fail = function( error )
    16.     {
    17.         // error will contain the error description
    18.         // posible errors are 'emptydir' 'notfound' 'serverNotFound'
    19.     }
    20.     IOSFileSync.listDir( dir ).then( success, fail );
    复制代码
    IOSFileSync.upload

    1.   var progress = function( percentage )
    2.     {
    3.         console.log( 'Uploaded '+percentage+'%');
    4.     }

    5.     IOSFileSync.upload(
    6.         file /* File object */,
    7.         path /* you can provide a relative path from the default upload path */
    8.     ).then(
    9.         success,
    10.         fail,
    11.         progresss
    12.     );        
    复制代码
    Basic Example

    Inside the example folder you can find a minimal example that lets you upload an image to the server.
    The image will be shown at the device, after that you can click on "Get upload dir contents" to get a list of the files inside the upload dir.
    License













    相关链接:

    https://github.com/xperiments/ANEFileSyncInterface


    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    守望者AIR技术交流社区(www.airmyth.com)
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    
    关闭

    站长推荐上一条 /4 下一条

    QQ|手机版|Archiver|网站地图|小黑屋|守望者 ( 京ICP备14061876号

    GMT+8, 2024-3-28 22:06 , Processed in 0.054321 second(s), 38 queries .

    守望者AIR

    守望者AIR技术交流社区

    本站成立于 2014年12月31日

    快速回复 返回顶部 返回列表