Raw Bind Upload File

@param rid      randomId of uploading file
@param callback file state callback
967721
@ObjectiveCName("bindRawUploadFileWithRid:withCallback:")
    public void bindRawUploadFile(long rid, UploadFileCallback callback) {
        modules.getFilesModule().bindUploadFile(rid, callback);
    }
1220253
public function sendfile($outfd, $cb, $startCb = null, $offset = 0, $length = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        static $chunkSize = 1024;
        $ret = true;

        $handler = function (
            $file,
            $sent = -1
        ) use (
            &$ret,
            $outfd,
            $cb,
            &$handler,
            &$offset,
            &$length,
            $pri,
            $chunkSize
        ) {
            if ($outfd instanceof IOStream) {
                if ($outfd->isFreed()) {
                    $cb($file, false);
                    return;
                }
                $ofd = $outfd->getFd();
            } else {
                $ofd = $outfd;
            }
            if (!$ret) {
                $cb($file, false);
                return;
            }
            if ($sent === -1) {
                $sent = 0;
            }
            $offset += $sent;
            $length -= $sent;
            if ($length <= 0) {
                $cb($file, true);
                return;
            }
            if (!$ofd) {
                $cb($file, false);
                return;
            }
            $c = min($chunkSize, $length);
            $ret = eio_sendfile($ofd, $file->fd, $offset, $c, $pri, $handler, $file);
        };
        if ($length !== null) {
            if ($startCb !== null) {
                if (!$startCb($this, $length, $handler)) {
                    $handler($this);
                }
            } else {
                $handler($this);
            }
            return true;
        }
        $this->statRefresh(function ($file, $stat) use ($startCb, $handler, &$length) {
            $length = $stat['size'];
            if ($startCb !== null) {
                if (!$startCb($file, $length, $handler)) {
                    $handler($file);
                }
            } else {
                $handler($file);
            }
        }, $pri);
        return true;
    }
752869
function load (url, callback, sendCallbackWhenAlreadyLoaded) {
        if (sendCallbackWhenAlreadyLoaded == undefined) {
            sendCallbackWhenAlreadyLoaded = true;
        }

        if (isLoaded(url)) {
            if (sendCallbackWhenAlreadyLoaded) {
                callback(url);
            }
            return;
        }

        if (isLoading(url) && !sendCallbackWhenAlreadyLoaded) {
            return;
        }

        var c = callbacks[url];
        if (!c) {
            var image = new Image();
            image.src = url;

            c = [];
            callbacks[url] = c;

            image.onload = function (event) {
                urls[url] = true;
                delete callbacks[url];

                for (var i = 0; i < c.length; i++) {
                    c[i](url);
                }
            }
        }

        if (c.indexOf(callback) == -1) {
            c.push(callback);
        }
    }
1120029
function(callback) {
        var headers     = this._formatHeaders(this.headers, this.params);
        if (this.payload != null) {
            headers['content-length'] = new Buffer(this.payload).length;
        } else if (this.method == 'POST' || this.method == 'DELETE' || this.method == 'PUT') {
            headers['content-length'] = 0;
        }
        var client = this.httpClient.http;
        if (this.scheme == 'https') client = this.httpClient.https;
        var httpRequest = client.request({port    : this.port,
                                          host    : this.host,
                                          method  : this.method,
                                          path    : this.uri,
                                          headers : headers},
                                         function(response) {
                                             var data = "";
                                             response.on('data', function(chunk) {
                                                 data += chunk;
                                             });
                                             response.on('end', function() {
                                                 var c = {
                                                     status  : response.statusCode,
                                                     headers : response.headers,
                                                     body    : data
                                                 };
                                                 callback(null, c);
                                             });
                                         });
        httpRequest.on('error', function(e) {
            callback(e, null);
        });
        if (this.payload !== null)
            httpRequest.write(this.payload);
        httpRequest.end();
    }
901246
function(callback, guid) {
		// If the guid has not been supplied then create a new one.
		guid = guid || '_hellojs_' + parseInt(Math.random() * 1e12, 10).toString(36);

		// Define the callback function
		window[guid] = function() {
			// Trigger the callback
			try {
				if (callback.apply(this, arguments)) {
					delete window[guid];
				}
			}
			catch (e) {
				console.error(e);
			}
		};

		return guid;
	}
201995
function uploadFiles(files) {
    var index = 0,
        file = files[index];

    /**
    * Recursive helper used as callback for server.raw(put)
    * @param {error} err - Error message if something went wrong
    */
    var processFile = function processFile (err) {
      if (err) {
        grunt.log.warn(messages.fileTransferFail(file.dest, err));
      } else {
        grunt.log.ok(messages.fileTransferSuccess(file.dest));
      }

      ++index;
      // If there are more files, then keep pushing
      if (index < files.length) {
        file = files[index];
        server.put(grunt.file.read(file.src, { encoding: null }), file.dest, processFile);
      } else {
        // Close the connection, we are complete
        server.raw('quit', function(quitErr) {
          if (quitErr) {
            grunt.log.error(quitErr);
            done(false);
          }
          server.destroy();
          grunt.log.ok(messages.connectionClosed);
          done();
        });
      }
    };

    // Start uploading files
    server.put(grunt.file.read(file.src, { encoding: null }), file.dest, processFile);
  }
953948
protected function _bind(array $callback) {
		if (true === empty($callback)) {
			return false;
		}
		array_map(function ($cb) {
			parent::on($cb['event'], $cb['callback']);
		}, $callback);
	}
136280
function(params, callback) {
                var uploadUniqueId,
                    uploadThreadId;

                var uploadFileData = {},
                    fileExtension;

                if (params) {
                    if (typeof params.fileUrl !== 'undefined') {
                        uploadFileData.url = params.fileUrl;
                    }

                    if (typeof params.fileExtension !== 'undefined') {
                        fileExtension = params.fileExtension;
                    }
                    else {
                        fileExtension = 'png';
                    }

                    if (typeof params.fileName == 'string') {
                        uploadFileData.filename = params.fileName;
                    }
                    else {
                        uploadFileData.filename = Utility.generateUUID() + '.' + fileExtension;
                    }

                    if (typeof params.uniqueId == 'string') {
                        uploadUniqueId = params.uniqueId;
                    }
                    else {
                        uploadUniqueId = Utility.generateUUID();
                    }

                    if (parseInt(params.threadId) > 0) {
                        uploadThreadId = params.threadId;
                    }
                    else {
                        uploadThreadId = 0;
                    }

                    uploadFileData.isPublic = true;
                }

                httpRequest({
                    url: SERVICE_ADDRESSES.POD_DRIVE_ADDRESS + SERVICES_PATH.DRIVE_UPLOAD_FILE_FROM_URL,
                    method: 'POST',
                    headers: {
                        '_token_': token,
                        '_token_issuer_': 1
                    },
                    data: uploadFileData,
                    uniqueId: uploadUniqueId
                }, function(result) {
                    if (!result.hasError) {
                        try {
                            var response = (typeof result.result.responseText == 'string')
                                ? JSON.parse(result.result.responseText)
                                : result.result.responseText;
                            callback({
                                hasError: response.hasError,
                                result: response.result
                            });
                        }
                        catch (e) {
                            callback({
                                hasError: true,
                                errorCode: 999,
                                errorMessage: 'Problem in Parsing result',
                                error: e
                            });
                        }
                    }
                    else {
                        callback({
                            hasError: true,
                            errorCode: result.errorCode,
                            errorMessage: result.errorMessage
                        });
                    }
                });

                return {
                    uniqueId: uploadUniqueId,
                    threadId: uploadThreadId,
                    participant: userInfo,
                    content: {
                        file: {
                            uniqueId: uploadUniqueId,
                            fileUrl: params.fileUrl
                        }
                    }
                };
            }
159522
function(id,callback){
    var item = fileCache.items[id];
    if(typeof item !== 'undefined'){
      var uses = item.uses;
      uses.push(Date.now());
      if(uses.length>=pillars.config.cacheMaxSamples){
        uses.splice(0,uses.length-pillars.config.cacheMaxSamples);
      }
      // All samples sum
      var timesum = 0;
      for(var i=0,l=uses.length;i<l;i++){
        timesum+=uses[i];
      }
      // Average timestamp of all samples for this item
      item.average = Math.round(timesum/uses.length);

      if(Date.now()<=item.timeStamp+5000){
        callback(null,item);
      } else {
        fileCache.file(id,callback,item);
      }
    } else {
      fileCache.file(id,callback);
    }
  }
262979
@Override
    public void uploadFailed(final FailedEvent event) {
        assertStateConsistency(fileUploadId, event.getFilename());

        if (!isUploadInterrupted()) {
            interruptUploadDueToUploadFailed();
        }
        publishUploadFailedAndFinishedEvent(fileUploadId, event.getReason());
    }
301921
def bind(self, callback, sender=None):
        ''''''
        key = (_make_id(callback), _make_id(sender))
        self.callbacks.append((key, callback))
326687
function(imageIdentifier, callback) {
        var url = this.getMetadataUrl(imageIdentifier);

        request.del(this.getSignedResourceUrl('DELETE', url), callback);
        return this;
    }
44756
public FileWidgetUpload getFile(final String fileId) {
		for (FileWidgetUpload file : getFiles()) {
			if (Util.equals(file.getFileId(), fileId)) {
				return file;
			}
		}
		return null;
	}
240139
function (data, fn) {
    this.store.generateBinId(data.length, 0, function generateBinId(err, id) {
      if (err) {
        return fn(err);
      }

      data.url = id;
      data.revision = 1;
      data.latest = true;
      data.streamingKey = this.createStreamingKey(id, data.revision);
      this.store.setBin(data, function (err, id) {
        data.id = id;
        fn(err || null, err ? undefined : data);
      });
    }.bind(this));
  }
26251
function(id, chunkIdx, response, xhr) {
            var chunkData = handler._getChunkData(id, chunkIdx);

            handler._getFileState(id).attemptingResume = false;

            delete handler._getFileState(id).temp.chunkProgress[chunkIdx];
            handler._getFileState(id).loaded += chunkData.size;

            options.onUploadChunkSuccess(id, handler._getChunkDataForCallback(chunkData), response, xhr);
        }
275080
public void moveToRecordId(RecordId rid) {
		moveTo(rid.block().number());
		rp.moveToId(rid.id());
	}
1054652
function(imageIdentifier, callback) {
        var url = this.getImageUrl(imageIdentifier).setPath('/shorturls'),
            signed = this.getSignedResourceUrl('DELETE', url);

        request.del(signed, callback);
        return this;
    }