Members
-
<static> saveAs
-
This is a wrapper around Eli Grey's saveAs function. This saves to the browser's downloads directory.
Methods
-
<static> buildDragNDropRegion(droptargetName, filesHandler)
-
Establish an area as a drag-n-drop drop site for files.
Parameters:
Name Type Description droptargetNameDOMString the id of the drag-and-drop site or the actual DOM object. filesHandlerFunction function that accepts an array of File's. -
<static> buildFileReceiver(acceptRejectCB, blobAcceptor, statusCB)
-
Enable datachannel based file receiving. The received blobs get passed to the statusCB in the 'eof' typed message.
Parameters:
Name Type Description acceptRejectCBFunction(otherGuy,fileNameList, wasAccepted this function is called when another peer (otherGuy) offers to send you a list of files. this function should call it's wasAccepted function with true to allow those files to be sent, or false to disallow them. blobAcceptorFunction this function is called three arguments arguments: the suppliers easyrtcid, a blob and a filename. It is responsible for saving the blob to the file, usually using easyrtc_ft.saveAs. statusCBtype this function is called with the current state of file receiving. It is passed two arguments: otherGuy - the easyrtcid of the person sending the files. * msg - one of the following structures: {status:"done", reason:"accept_failed"} {status:"done", reason:"success"} {status:"done", reason:"cancelled"} {status:"eof"}, {status:"started_file, name:"filename"} {status:"progress", name:filename, received:received_size_in_bytes, size:file_size_in_bytes } Example
easyrtc_ft( function(otherGuy, filenamelist, wasAccepted) { wasAccepted(true);}, function(otherGuy, blob, filename) { easyrtc_ft(blob, filename);}, function(otherGuy, status) { console.log("status:" + JSON.stringify(status))} ); -
<static> buildFileSender(destUser, progressListener) → {Function}
-
Builds a function that can be used to send a group of files to a peer.
Parameters:
Name Type Description destUserString easyrtcid of the person being sent to. progressListenerFunction if provided, is called with the following objects: {status:"waiting"} // once a file offer has been sent but not accepted or rejected yet {status:"started_file", name: filename} {status:"working", name:filename, position:position_in_file, size:size_of_current_file, numFiles:number_of_files_left} {status:"cancelled"} // if the remote user cancels the sending {status:"done"} // when the file is done the progressListener should always return true for normal operation, false to cancel a filetransfer. Returns:
an object that accepts an array of File (the Files to be sent), and a boolean argument that is true if the files are binary, false if they are text. It is safe to treat all files as binary, it will just require more bandwidth.- Type
- Function