0

I have found this cool file-upload repo by mailru, it called FileAPI. The FileAPI uses .swf file as debugging tool. How this works without embedding the .swf file??

2 Answers 2

1

How this works without embedding the .swf file??

They seem to be dynamically updating the html page (to now have the SWF embeded). This means using innerHTML to generate new content which was not originally coded in the html file. You can check a basic guide about innerHTML here.

Looking at FileAPI.js, onwards from line 3590 we see they indeed use innerHTML to embed a Flash object. It becomes embeded (dynamically) when the right Javascript function is triggered.

Some short snippet of their code is below :

/**
 * Publish flash-object
 *
 * @param {HTMLElement} el
 * @param {String} id
 * @param {Object} [opts]
 */
publish: function (el, id, opts){
    opts = opts || {};
    el.innerHTML = _makeFlashHTML({
          id: id
        , src: _getUrl(api.flashUrl, 'r=' + api.version)
        //, src: _getUrl('http://v.demidov.boom.corp.mail.ru/uploaderfileapi/FlashFileAPI.swf?1')
        , wmode: opts.camera ? '' : 'transparent'
        , flashvars: 'callback=' + (opts.onEvent || 'FileAPI.Flash.onEvent')
            + '&flashId='+ id
            + '&storeKey='+ navigator.userAgent.match(/\d/ig).join('') +'_'+ api.version
            + (flash.isReady || (api.pingUrl ? '&ping='+api.pingUrl : ''))
            + '&timeout='+api.flashAbortTimeout
            + (opts.camera ? '&useCamera=' + _getUrl(api.flashWebcamUrl) : '')
            + '&debug='+(api.debug?"1":"")
    }, opts);
},

... etc etc etc ...
Sign up to request clarification or add additional context in comments.

Comments

0

They can use the File API. Don't confuse it with a name of the Mail.ru library. See this links: https://developer.mozilla.org/en/docs/Web/API/File https://developer.mozilla.org/ru/docs/Web/API/XMLHttpRequest#sendAsBinary()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.