/* See also the .htaccess file.   Many MySQL servers are configured to have a max size of a
blob as 1MB.  if you change the .htaccess you need to change the mysql configuration as well.
this may not be possible on a low-cst provider.
761944
public static function maxUpload() {
        $maxUpload = (int)(ini_get('upload_max_filesize'));
        $max_post = (int)(ini_get('post_max_size'));
        $memory_limit = (int)(ini_get('memory_limit'));
        $upload_mb = min($maxUpload, $max_post, $memory_limit);
        return $upload_mb;
    }
1186471
public static function getFileUploadMaxSize($convert_to_bytes = true)
    {
        $max_size = -1;
        $max_size_string = '0B';

        if ($max_size < 0) {
            // Start with post_max_size.
            $max_size_string = ini_get('post_max_size');
            $max_size = self::parseSize($max_size_string);

            // If upload_max_size is less, then reduce. Except if upload_max_size is
            // zero, which indicates no limit.
            $upload_max = self::parseSize(ini_get('upload_max_filesize'));
            if ($upload_max > 0 && $upload_max < $max_size) {
                $max_size = $upload_max;
                $max_size_string = ini_get('upload_max_filesize');
            }
        }

        return $convert_to_bytes ? $max_size : $max_size_string;
    }
345706
function(link, cb){
            var id = Math.abs(crc32.str(md5(link)));
            
            var options = {
                host: urlArr.hostname,
                port: urlArr.port,
                path: "/delete/"+id,
                method: 'DELETE',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            };
                                    
            var deleteRequest = protocol.request(options, function(res){
                var result = "";
                
                if(res.statusCode === 200){
                    res.on('error', function(error){
                        if(typeof cb === "function")
                            cb(error);
                    });

                    res.on('data', function(chunk){
                        result += chunk;
                    });

                    res.on('end', function(chunk){
                        if(typeof cb === "function"){
                            var resultObj = JSON.parse(result);
                            var err = (resultObj.status === "error") ? resultObj["msg"] : null
                            cb(err, resultObj);
                        }    
                    });
                }
                else{
                    if(typeof cb === "function")
                        cb("Request return HTTP "+res.statusCode);
                }
            });
            
            deleteRequest.end();
        }
511976
function checkFileSizeLimit(client, srcList) {
  function maxSizeExceeded(obj) {
    var errorMsg;

    client.lock.release(function(err) {
      if(err) {
        log.error({err: err, client: client}, 'Error releasing sync lock');
      }

      releaseLock(client);

      errorMsg = SyncMessage.error.maxsizeExceeded;
      errorMsg.content = {path: obj.path};
      client.sendMessage(errorMsg);
    });
  }

  for (var key in srcList) {
    if(srcList.hasOwnProperty(key)) {
      var obj = srcList[key];
      for (var prop in obj) {
        if(obj.hasOwnProperty(prop) && prop === 'size') {
          if(obj.size > MAX_SYNC_SIZE_BYTES) {
            // Fail this sync, contains a file that is too large.
            log.warn({client: client},
                     'Client tried to exceed file sync size limit: file was %s bytes, limit is %s',
                     obj.size, MAX_SYNC_SIZE_BYTES);
            maxSizeExceeded(obj);
            return false;
          }
        }
      }
    }
  }

  return true;
}
560760
public long size64() throws SQLException {
    long cp = tell64();
    seek64(0, SEEK_END);
    long sz = tell64();
    seek64(cp, SEEK_SET);
    return sz;
  }
924729
def cmd_size(param)
      send_unauthorised and return unless logged_in?
      send_param_required and return if param.nil?

      @driver.bytes(build_path(param)) do |bytes|
        if bytes
          send_response "213 #{bytes}"
        else
          send_response "450 file not available"
        end
      end
    end
823328
protected function renderMaximumFileUploadSize()
    {
        $maximumFileUploadSizeInBytes = min(Files::sizeStringToBytes(ini_get('post_max_size')), Files::sizeStringToBytes(ini_get('upload_max_filesize')));
        return sprintf('"%d"; // %s, as configured in php.ini', $maximumFileUploadSizeInBytes, Files::bytesToSizeString($maximumFileUploadSizeInBytes));
    }
334673
private static function getUploadMaxFileSizeInBytes() {
    $val = trim(ini_get('upload_max_filesize'));
    $unit = strtolower(substr($val, -1));
    switch ($unit) {
      case 'g':
        $val *= 1024;
        // Fall through
      case 'm':
        $val *= 1024;
        // Fall through
      case 'k':
        $val *= 1024;
        break;
    }
    return intval($val);
  }
532505
public function getMaxUploadSize()
    {
        $maxUpload = (int)(ini_get('upload_max_filesize'));
        $maxPost = (int)(ini_get('post_max_size'));
        $memoryLimit = (int)(ini_get('memory_limit'));
        return min($maxUpload, $maxPost, $memoryLimit);
    }
1363709
private function getSizeFromMetadata()
    {
        foreach ($this->stream->getMetadata('wrapper_data') as $value) {
            if (substr($value, 0, 15) == "Content-Length:") {
                return (int) substr($value, 16);
            }
        }
        return 0;
    }
497864
def blob_delete(table, digest)
      uri = blob_path(table, digest)
      @logger.debug("BLOB DELETE #{uri}")
      req = Net::HTTP::Delete.new(uri, headers)
      response = request(req)
      case response.code
      when '200'
        true
      else
        @logger.info("Response #{response.code}: #{response.body}")
        false
      end
    end
105417
function(size) {
    var match;
    var buffer;
    if (match = size.match(/(\d+)KB/)) {
      buffer = new Buffer(parseInt(match[1]) * 1024);
    } else if (match = size.match(/(\d+)MB/)) {
      buffer = new Buffer(parseInt(match[1]) * 1024 * 1024);
    } else {
      switch (size) {
        case 'empty': buffer = new Buffer(0); break;
        case 'small': buffer = new Buffer(1024 * 1024); break;
        case 'large': buffer = new Buffer(1024 * 1024 * 20); break;
        default: return new Buffer(1024 * 1024);
      }
    }
    buffer.fill('x');
    return buffer;
  }
359578
public synchronized long length() throws SQLException {

        try {
            return blob.length(session);
        } catch (HsqlException e) {
            throw Util.sqlException(e);
        }
    }
1325818
def validate_instance_dbname(self, dbname):
        '''  '''
        # 1-64 alphanumeric characters, cannot be a reserved MySQL word
        if re.match('[\w-]+$', dbname) is not None:
            if len(dbname) <= 41 and len(dbname) >= 1:
                if dbname.lower() not in MYSQL_RESERVED_WORDS:
                    return True
        return '*** Error: Database names must be 1-64 alphanumeric characters,\
            cannot be a reserved MySQL word.'
1224094
protected function getAutomaticChunkSize()
    {
        $nh = $this->app->make('helper/number');
        // Maximum size of an uploaded file, minus a small value (just in case)
        $uploadMaxFilesize = (int) $nh->getBytes(ini_get('upload_max_filesize')) - 100;
        // Max size of post data allowed, minus enough space to consider other posted fields.
        $postMaxSize = (int) $nh->getBytes(ini_get('post_max_size')) - 10000;
        if ($uploadMaxFilesize < 1 && $postMaxSize < 1) {
            return 2000000;
        }
        if ($uploadMaxFilesize < 1) {
            return $postMaxSize;
        }
        if ($postMaxSize < 1) {
            return $uploadMaxFilesize;
        }

        return min($uploadMaxFilesize, $postMaxSize);
    }
165183
private function maxLength()
	{
		$max = mb_strlen($this->value);
		if (!$ret = $max <= $this->options->max) {
			$this->error(1);
		}

		return $ret;
	}
64386
public function byteSize()
    {
        return mb_strlen($this->name) +
                mb_strlen($this->type) +
                mb_strlen($this->value);
    }