Partitions the file and saves the parts to be uploaded
        in memory.
14503
def get_parts(self):
        
        parts = []
        start_byte = 0
        for i in range(1, self.total + 1):
            end_byte = start_byte + self.part_size
            if end_byte >= self.file_size - 1:
                end_byte = self.file_size
            parts.append({
                'part': i,
                'offset': start_byte,
                'limit': end_byte
            })
            start_byte = end_byte
        return parts
25246
public function save()
    {
        $filepath = $this->getFilepath();
        $this->validateConfig($this->rules, $this->configData);
        $fileSystem = $this->createNew(FileSystem::class);
        $fileSystem->filePutContents($filepath, json_encode($this->configData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
    }
1330806
def save
      self.queue.each do |style, file|
        path = self.path(style)
        self.storage.save(file, path) if file and path
      end
      self.purge.each do |path|
        self.storage.destroy(path)
      end
      @purge = []
      @queue = {}
    end
471972
function onPart (part) {
  var form = this;

  if (undefined === part.filename) return form.handlePart(part);

  ++form._flushing;

  var file = new File(part.filename, form.__filename(part.filename), part.mime);

  form.emit('fileBegin', part.name, file);

  var options = { mode: 'w', content_type: file.type, filename: file.path };
  if (form.chunk_size) options.chunk_size = form.chunk_size;
  if (form.root) options.root = form.root;
  options.metadata = file.metadata ? file.metadata
                   : form.metadata ? form.metadata
                   : undefined
  var ws = form.__gridstream.createWriteStream(options);

  ws.on('progress', onprogress);
  ws.on('drain', resume);
  ws.once('error', done);
  part.on('data', onData);
  part.once('end', onEnd);

  function onprogress (size) {
    file.lastModified = new Date;
    file.size = size;
    file.emit('progress', size);
  }

  function resume () {
    form.resume();
  };

  function onData (data) {
    form.pause();
    ws.write(data);
  };

  function onEnd () {
    part.removeListener('data', onData);
    part.removeListener('end', onEnd);
    ws.once('close', function (_) {
      done();
    });
    ws.end();
  };

  function done (err) {
    if (done.err) return;
    if (err) return form.emit('error', done.err = err);

    ws.removeListener('progress', onprogress);
    ws.removeListener('drain', resume);
    ws.removeListener('error', done);

    file.id || (file.id = ws._store.fileId);
    file.root = ws._store.root;
    file.size = ws._store.position;
    file.emit('end');

    --form._flushing;

    form.emit('file', part.name, file);
    form._maybeEnd();
  }
}
1295350
public void setHashPartitioned(FieldList partitionedFields) {
		this.partitioning = PartitioningProperty.HASH_PARTITIONED;
		this.partitioningFields = partitionedFields;
		this.ordering = null;
	}
296971
void rollIfNeeded() throws IOException {
    if (numberOfParts == 1 || numberOfFiles < 1) {
      return;
    }
    filesCount++;
    if (filesCount % filesPerRoll == 0) {
      out.close();
      currentPart++;
      createOutputStream();
    }
  }
356203
def _save_file(self, data, path):
        
        with open(path, 'wb') as tfile:
            for chunk in data:
                tfile.write(chunk)
1224445
def put(localpath, destpath)
      create(destpath) { |dest|
        Kernel.open(localpath) { |source|
          # read 1 MB at a time
          while record = source.read(1048576)
            dest.write(record)
          end
        }
      }
    end
35165
public function save()
    {
        foreach ($this->data as $key => $value) {
            if (!empty($value)) {
                $this->parametersStorage->set($key, $value);
            } else {
                // Remove value to use default
                $this->parametersStorage->remove($key);
            }
        }
    }
1220286
private void compactPartition(int partitionNumber) throws IOException {
		// stop if no garbage exists
		if(this.partitions.get(partitionNumber).isCompacted()) {
			return;
		}
		// release all segments owned by compaction partition
		this.compactionMemory.clearAllMemory(availableMemory);
		this.compactionMemory.allocateSegments(1);
		T tempHolder = this.buildSideSerializer.createInstance();
		InMemoryPartition<T> partition = this.partitions.remove(partitionNumber);
		final int numPartitions = this.partitions.size() + 1; // dropped one earlier
		long pointer = 0L;
		int pointerOffset = 0;
		int bucketOffset = 0;
		final int bucketsPerSegment = this.bucketsPerSegmentMask + 1;
		for (int i = 0, bucket = partitionNumber; i < this.buckets.length && bucket < this.numBuckets; i++) {
			MemorySegment segment = this.buckets[i];
			// go over all buckets in the segment belonging to the partition
			for (int k = bucket % bucketsPerSegment; k < bucketsPerSegment && bucket < this.numBuckets; k += numPartitions, bucket += numPartitions) {
				bucketOffset = k * HASH_BUCKET_SIZE;
				if((int)segment.get(bucketOffset + HEADER_PARTITION_OFFSET) != partitionNumber) {
					throw new IOException("Accessed wrong bucket! ");
				}
				int count = segment.getInt(bucketOffset + HEADER_COUNT_OFFSET);
				for (int j = 0; j < NUM_ENTRIES_PER_BUCKET && j < count; j++) {
					pointerOffset = bucketOffset + BUCKET_POINTER_START_OFFSET + (j * POINTER_LEN);
					pointer = segment.getLong(pointerOffset);
					partition.readRecordAt(pointer, tempHolder);
					pointer = this.compactionMemory.appendRecord(tempHolder);
					segment.putLong(pointerOffset, pointer);
				}
				long overflowPointer = segment.getLong(bucketOffset + HEADER_FORWARD_OFFSET);
				if(overflowPointer != BUCKET_FORWARD_POINTER_NOT_SET) {
					// scan overflow buckets
					int current = NUM_ENTRIES_PER_BUCKET;
					bucketOffset = (int) (overflowPointer & 0xffffffff);
					pointerOffset = ((int) (overflowPointer & 0xffffffff)) + BUCKET_POINTER_START_OFFSET;
					int overflowSegNum = (int) (overflowPointer >>> 32);
					count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET);
					while(current < count) {
						pointer = partition.overflowSegments[overflowSegNum].getLong(pointerOffset);
						partition.readRecordAt(pointer, tempHolder);
						pointer = this.compactionMemory.appendRecord(tempHolder);
						partition.overflowSegments[overflowSegNum].putLong(pointerOffset, pointer);
						current++;
						if(current % NUM_ENTRIES_PER_BUCKET == 0) {
							count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET);
							overflowPointer = partition.overflowSegments[overflowSegNum].getLong(bucketOffset + HEADER_FORWARD_OFFSET);
							if(overflowPointer == BUCKET_FORWARD_POINTER_NOT_SET) {
								break;
							}
							overflowSegNum = (int) (overflowPointer >>> 32);
							bucketOffset = (int) (overflowPointer & 0xffffffff);
							pointerOffset = ((int) (overflowPointer & 0xffffffff)) + BUCKET_POINTER_START_OFFSET;
						} else {
							pointerOffset += POINTER_LEN;
						}
					}
				}
			}
		}
		// swap partition with compaction partition
		this.compactionMemory.setPartitionNumber(partitionNumber);
		this.partitions.add(partitionNumber, compactionMemory);
		this.compactionMemory = partition;
		this.partitions.get(partitionNumber).overflowSegments = this.compactionMemory.overflowSegments;
		this.partitions.get(partitionNumber).numOverflowSegments = this.compactionMemory.numOverflowSegments;
		this.partitions.get(partitionNumber).nextOverflowBucket = this.compactionMemory.nextOverflowBucket;
		this.partitions.get(partitionNumber).setCompaction(true);
		this.compactionMemory.resetRecordCounter();
		this.compactionMemory.setPartitionNumber(-1);
		// try to allocate maximum segment count
		int maxSegmentNumber = 0;
		for (InMemoryPartition<T> e : this.partitions) {
			if(e.getBlockCount() > maxSegmentNumber) {
				maxSegmentNumber = e.getBlockCount();
			}
		}
		this.compactionMemory.allocateSegments(maxSegmentNumber);
		if(this.compactionMemory.getBlockCount() > maxSegmentNumber) {
			this.compactionMemory.releaseSegments(maxSegmentNumber, availableMemory);
		}
	}
601330
def save(self, filething=None, v2_version=4, v23_sep='/', padding=None):
        """"""

        fileobj = filething.fileobj

        iff_file = IFFFile(fileobj)

        if u'ID3' not in iff_file:
            iff_file.insert_chunk(u'ID3')

        chunk = iff_file[u'ID3']

        try:
            data = self._prepare_data(
                fileobj, chunk.data_offset, chunk.data_size, v2_version,
                v23_sep, padding)
        except ID3Error as e:
            reraise(error, e, sys.exc_info()[2])

        new_size = len(data)
        new_size += new_size % 2  # pad byte
        assert new_size % 2 == 0
        chunk.resize(new_size)
        data += (new_size - len(data)) * b'\x00'
        assert new_size == len(data)
        chunk.write(data)
1354356
def save(self):
        """"""

        with open(self.store_file_path, 'w') as fh:
            fh.write(json.dumps(self.store, indent=4))
903359
public function save()
    {
        $contents = $this->getForStorage();

        $this->repository->put($this->key, $contents, $this->expire);
    }
1167752
@Override
	public void releaseMemory(int toRelease) throws IOException {
		checkArgument(toRelease > 0);

		for (ResultSubpartition subpartition : subpartitions) {
			toRelease -= subpartition.releaseMemory();

			// Only release as much memory as needed
			if (toRelease <= 0) {
				break;
			}
		}
	}
332936
def save(self):
        
        if self.mode in ("wb+", 'rb+'):
            if not self.is_open:
                raise IOError("file closed")
            self.write_reference_properties()
            self.manager.write_objects()
56515
public static void splitFile(File file, long[] splitPoints, String storageFolder) throws IOException {
        splitPoints = ArrayUtils.concatArrays(new long[]{0}, splitPoints, new long[]{file.length()});
        String[] fileName = file.getName().split("\\.", 2);
        storageFolder += ValueConsts.SEPARATOR;
        logger.info("start to split file '" + file.getAbsolutePath() + "'");
        for (int i = 0; i < splitPoints.length - 1; i++) {
            long start = splitPoints[i], end = splitPoints[i + 1];
            long length = end - start;
            String filePath = storageFolder + fileName[0] + "_" + (i + 1) + "." + fileName[1];
            createNewFile(filePath);
            while (length > Integer.MAX_VALUE) {
                saveFile(filePath, readFile(file, start, Integer.MAX_VALUE), true);
                start += Integer.MAX_VALUE;
                length -= Integer.MAX_VALUE;
            }
            if (length > 0) {
                saveFile(filePath, readFile(file, start, (int) length), true);
            }
        }
    }
335054
protected final void addAllFilesToSuccessfullyUploadedFiles() {
        for (Iterator<UploadFile> iterator = params.files.iterator(); iterator.hasNext(); ) {
            UploadFile file = iterator.next();

            if (!successfullyUploadedFiles.contains(file.path)) {
                successfullyUploadedFiles.add(file.path);
            }
            iterator.remove();
        }
    }