Upload files that were too large.
177027
def upload_large_items(self):
        
        for local_file, parent in self.large_items:
            if local_file.need_to_send:
                self.process_large_file(local_file, parent)
610964
def _upload_in_splits( self, destination_folder_id, source_path, preflight_check, verbose = True, chunked_upload_threads = 5 ):
        '''
        
        '''
        file_size = os.stat(source_path).st_size
        split_size = BOX_MAX_FILE_SIZE

        # Make sure that the last split piece is still big enough for a chunked upload
        while file_size % split_size < BOX_MIN_CHUNK_UPLOAD_SIZE:
            split_size -= 1000
            if split_size < BOX_MIN_CHUNK_UPLOAD_SIZE:
                raise Exception('Lazy programming error')

        split_start_byte = 0
        part_count = 0
        uploaded_file_ids = []
        while split_start_byte < file_size:
            dest_file_name = '{0}.part{1}'.format( os.path.basename(source_path), part_count)
            prev_uploaded_file_ids = self.find_file( destination_folder_id, dest_file_name )
            if len( prev_uploaded_file_ids ) == 1:
                if verbose:
                    print ( '\nSkipping upload of split {0} of {1}; already exists'.format( part_count + 1, math.ceil(file_size / split_size) ) )
                uploaded_file_ids.extend( prev_uploaded_file_ids )
            else:
                if verbose:
                    print ( '\nUploading split {0} of {1}'.format( part_count + 1, math.ceil(file_size / split_size) ) )
                uploaded_file_ids.append( self._chunked_upload(
                    destination_folder_id, source_path,
                    dest_file_name = dest_file_name,
                    split_start_byte = split_start_byte,
                    file_size = min(split_size, file_size - split_start_byte), # Take the min of file_size - split_start_byte so that the last part of a split doesn't read into the next split
                    preflight_check = preflight_check,
                    verbose = verbose,
                    upload_threads = chunked_upload_threads,
                ) )
            part_count += 1
            split_start_byte += split_size

        return uploaded_file_ids
765242
def create(cls, bucket, key, size, chunk_size):
        """"""
        bucket = as_bucket(bucket)

        if bucket.locked:
            raise BucketLockedError()

        # Validate chunk size.
        if not cls.is_valid_chunksize(chunk_size):
            raise MultipartInvalidChunkSize()

        # Validate max theoretical size.
        if not cls.is_valid_size(size, chunk_size):
            raise MultipartInvalidSize()

        # Validate max bucket size.
        bucket_limit = bucket.size_limit
        if bucket_limit and size > bucket_limit:
            desc = 'File size limit exceeded.' \
                if isinstance(bucket_limit, int) else bucket_limit.reason
            raise FileSizeError(description=desc)

        with db.session.begin_nested():
            file_ = FileInstance.create()
            file_.size = size
            obj = cls(
                upload_id=uuid.uuid4(),
                bucket=bucket,
                key=key,
                chunk_size=chunk_size,
                size=size,
                completed=False,
                file=file_,
            )
            bucket.size += size
            db.session.add(obj)
        file_.init_contents(
            size=size,
            default_location=bucket.location.uri,
            default_storage_class=bucket.default_storage_class,
        )
        return obj
1001097
@Override
    protected void uploadTusFiles() throws IOException, ProtocolException {
        setState(State.UPLOADING);
        while (uploads.size() > 0) {
            final TusUploader tusUploader;
            // don't recreate uploader if it already exists.
            // this is to avoid multiple connections being open. And to avoid some connections left unclosed.
            if (lastTusUploader != null) {
                tusUploader = lastTusUploader;
                lastTusUploader = null;
            } else {
                tusUploader = tusClient.resumeOrCreateUpload(uploads.get(0));
                if (getUploadChunkSize() > 0) {
                    tusUploader.setChunkSize(getUploadChunkSize());
                }
            }

            TusExecutor tusExecutor = new TusExecutor() {
                @Override
                protected void makeAttempt() throws ProtocolException, IOException {
                    while (state == State.UPLOADING) {
                        int chunkUploaded = tusUploader.uploadChunk();
                        if (chunkUploaded > 0) {
                            uploadedBytes += chunkUploaded;
                            listener.onUploadPogress(uploadedBytes, totalUploadSize);
                        } else {
                            // upload is complete
                            break;
                        }
                    }
                }
            };

            tusExecutor.makeAttempts();
            if (state != State.UPLOADING) {
                // if upload is paused, save the uploader so it can be reused on resume, then leave the method early.
                lastTusUploader = tusUploader;
                return;
            }

            // remove upload instance from list
            uploads.remove(0);
            tusUploader.finish();
        }

        setState(State.UPLOAD_COMPLETE);
    }
877606
def size_limit(self):
        
        limits = [
            lim for lim in current_files_rest.file_size_limiters(
                self)
            if lim.limit is not None
        ]
        return min(limits) if limits else None
495140
public long getFileBytesMaxUploadSize(CmsObject cms) {

        int maxFileSize = getFileMaxUploadSize();
        long maxFileSizeBytes = maxFileSize * 1024;
        // check if current user belongs to Admin group, if so no file upload limit
        if ((maxFileSize <= 0) || OpenCms.getRoleManager().hasRole(cms, CmsRole.VFS_MANAGER)) {
            maxFileSizeBytes = -1;
        }
        return maxFileSizeBytes;
    }
1320300
def _upload_files(item, files, upload_kwargs, prev_identifier=None, archive_session=None):
    """"""
    responses = []
    if (upload_kwargs['verbose']) and (prev_identifier != item.identifier):
        print('{0}:'.format(item.identifier))

    try:
        response = item.upload(files, **upload_kwargs)
        responses += response
    except HTTPError as exc:
        responses += [exc.response]
    finally:
        # Debug mode.
        if upload_kwargs['debug']:
            for i, r in enumerate(responses):
                if i != 0:
                    print('---')
                headers = '\n'.join(
                    [' {0}:{1}'.format(k, v) for (k, v) in r.headers.items()]
                )
                print('Endpoint:\n {0}\n'.format(r.url))
                print('HTTP Headers:\n{0}'.format(headers))
                return responses

        # Format error message for any non 200 responses that
        # we haven't caught yet,and write to stderr.
        if responses and responses[-1].status_code and responses[-1].status_code != 200:
            if not responses[-1].status_code:
                return responses
            filename = responses[-1].request.url.split('/')[-1]
            try:
                msg = get_s3_xml_text(responses[-1].content)
            except:
                msg = responses[-1].content
            print(' error uploading {}: {}'.format(filename, msg), file=sys.stderr)

    return responses
527057
def resize(self, new_data_size):
        """"""

        resize_bytes(
            self.__fileobj, self.data_size, new_data_size, self.data_offset)
        self._update_size(new_data_size)
2565
def size(filename)
      voidcmd("TYPE I")
      resp = sendcmd("SIZE " + filename)
      if resp[0, 3] != "213" 
	raise FTPReplyError, resp
      end
      return resp[3..-1].strip.to_i
    end
678616
def fileSize(f):
    ''''''
    offset = f.tell()

    f.seek(0, 2)
    size = f.tell()

    f.seek(offset)  # return to the previous position in the file
    return size
597034
def filesize(num_bytes):
    """"""
    for prefix in '-KMGTEPZY':
        if num_bytes < 999.9:
            break
        num_bytes /= 1000.0
    if prefix == '-':
        return '{} B'.format(num_bytes)
    return '{:.3n} {}B'.format(num_bytes, prefix)
745431
public function isValidSize()
    {
        // If file was blocked via PHP for being excessive size, shortcut here
        switch ($this->tmpFile['error']) {
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                return false;
        }
        $maxSize = $this->getAllowedMaxFileSize($this->getFileExtension());
        return (!$this->tmpFile['size'] || !$maxSize || (int)$this->tmpFile['size'] < $maxSize);
    }
524607
function(size) {

		if (size === undef || /\D/.test(size)) {
			return plupload.translate('N/A');
		}

		function round(num, precision) {
			return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
		}

		var boundary = Math.pow(1024, 4);

		// TB
		if (size > boundary) {
			return round(size / boundary, 1) + " " + plupload.translate('tb');
		}

		// GB
		if (size > (boundary/=1024)) {
			return round(size / boundary, 1) + " " + plupload.translate('gb');
		}

		// MB
		if (size > (boundary/=1024)) {
			return round(size / boundary, 1) + " " + plupload.translate('mb');
		}

		// KB
		if (size > 1024) {
			return Math.round(size / 1024) + " " + plupload.translate('kb');
		}

		return size + " " + plupload.translate('b');
	}
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));
    }
67679
def show_big_file(dir_path, threshold):
        
        fc = FileCollection.from_path_by_size(dir_path, min_size=threshold)
        fc.sort_by("size_on_disk")
        
        lines = list()
        lines.append("Results:")
        for winfile in fc.iterfiles():
            lines.append("  %s - %s" % 
                         (string_SizeInBytes(winfile.size_on_disk), winfile))
        lines.append("Above are files' size greater than %s." % 
              string_SizeInBytes(threshold))
        text = "\n".join(lines)
        print(text)
        with open("__show_big_file__.log", "wb") as f:
            f.write(text.encode("utf-8"))
625804
protected void uploadTusFiles() throws IOException, ProtocolException {
        while (uploads.size() > 0) {
            final TusUploader tusUploader = tusClient.resumeOrCreateUpload(uploads.get(0));

            TusExecutor tusExecutor = new TusExecutor() {
                @Override
                protected void makeAttempt() throws ProtocolException, IOException {
                    int uploadedChunk = 0;
                    while (uploadedChunk > -1) {
                        uploadedChunk = tusUploader.uploadChunk();
                    }
                    tusUploader.finish();
                }
            };

            tusExecutor.makeAttempts();
            // remove upload instance from list
            uploads.remove(0);
        }
    }
1295816
private void rollOverFiles() {

        Context context = appContextRef.get();

        if (context != null) {

            File dir = context.getFilesDir();

            File mainFile = new File(dir, name(1));

            if (mainFile.exists()) {

                float fileSize = mainFile.length();
                fileSize = fileSize / 1024.0f; //In kilobytes

                if (fileSize > fileSizeLimitKb) {

                    File file;
                    File target;

                    file = new File(dir, name(maxFiles));
                    if (file.exists()) {
                        file.delete();
                    }

                    for (int i = maxFiles - 1; i > 0; i--) {
                        file = new File(dir, name(i));
                        if (file.exists()) {
                            target = new File(dir, name(i + 1));
                            file.renameTo(target);
                        }
                    }
                }
            }
        }
    }