save uploaded file to new location
770144
public static void writeToFile(InputStream uploadedInputStream,
                                 String uploadedFileLocation) throws IOException {
    File file = new File(uploadedFileLocation);
    file.getParentFile().mkdirs();

    int read = 0;
    byte[] bytes = new byte[1024];

    try (OutputStream out = new FileOutputStream(file)) {
      while ((read = uploadedInputStream.read(bytes)) != -1) {
        out.write(bytes, 0, read);
      }
      out.flush();
    }
  }
914341
private function _save() {
    unlink($this->path);
    file_put_contents($this->path,join('\n',$this->htpwd));
  }
180302
function onFile(__newFile, encoding, done) {
  var buffers = [];
  var options = this.options;

  // Check the file limit
  if (options.perMaxBytes && __newFile.byteCount > options.perMaxBytes) {
    return done(new Error('The file \'' + __newFile.filename + '\' beyond size limit, only accept less than ' + options.perMaxBytes + ' bytes'));
  }

  // Check the accept content type
  if (options.acceptTypes && options.acceptTypes.indexOf(__newFile.headers['content-type']) === -1) {
    return done(new Error('Content-type of the file \'' + __newFile.filename + '\' does not accepted'));
  }

  // Determine the file descriptor-- the unique identifier.
  // Often represents the location where file should be written.
  __newFile.fd;
  var uploadDir = __newFile.fd;
  if (uploadDir.substr(0, 1) !== '/') {
    uploadDir = '/' + uploadDir;
  }

  // When then 'data' event emited, push the chunk to the buffers array.
  __newFile.on('data', function (chunk) {
    buffers.push(chunk);
  });

  // When the 'end' event emited, upload the 'buffers' to the upyun server.
  __newFile.on('end', function () {
    var buffer = Buffer.concat(buffers);
    uploadToUpyun.bind({ options })(uploadDir, buffer, __newFile, done);
  });
}
78823
private function moveFile($upload_file, $cus_name, $can_make_watermark = false)
    {
        $suffix = $upload_file->getClientOriginalExtension();

        if (empty($cus_name)) {
            $original_name = uniqid();
        } else {
            $original_name = $cus_name;
        }
        $filename = $original_name . (!empty($suffix) ? '.' . $suffix : '');

        $img = $this->setTmpImage($upload_file);

        Storage::put(
            $this->basepath . $filename,
            file_get_contents($upload_file->getRealPath()),
            $this->visibility
        );

        File::delete($upload_file->getRealPath());

        if (!is_null($img) && !empty($this->getThumbSizes())) {
            $this->saveThumb($img, $original_name, $suffix);
            $this->saveCompress($img, $original_name, $suffix);
            if ($can_make_watermark) {
                $this->mergeWatermark($img, $original_name, $suffix);
            }
        }

        return $filename;
    }
108264
def _save_file(self, filename, contents):
        """"""
        with open(filename, 'w') as f:
            f.write(contents)
1181627
function (files) {
      UI.widgets.uploadFiles(kb.fetcher, files, subject.uri, subject.uri, function (file, uri) {
        // A file has been uploaded
        let destination = kb.sym(uri)
        console.log(' Upload: put OK: ' + destination)
        kb.add(subject, ns.ldp('contains'), destination, subject.doc())
        mainTable.refresh()
      })
    }
785821
def upload(client, source_dir):
    """"""
    print('')
    print('upload store listings')
    print('---------------------')
    listings_folder = os.path.join(source_dir, 'listings')
    langfolders = filter(os.path.isdir, list_dir_abspath(listings_folder))

    for language_dir in langfolders:
        language = os.path.basename(language_dir)
        with open(os.path.join(language_dir, 'listing.json')) as listings_file:
            listing = json.load(listings_file)
        listing_response = client.update(
            'listings', language=language, body=listing)

        print('  Listing for language %s was updated.' %
              listing_response['language'])
1111815
def save(self):
        """"""
        file_name = fd.asksaveasfilename()
        if file_name is "" or file_name is None:
            return
        with open(file_name, "w") as f:
            f.write(self.text.get("1.0", tk.END))
640207
protected function uploadFile () : bool
	{
		// Determine the destination
		$this->newFileLocation = $this->getUploadDir().$this->uploadFileDir.getConstant('DS', TRUE).$this->newFileName;			  
		// Make sure a file doesn't already exist in the target location
		if (file_exists($this->newFileLocation)):
			$this->error = "The file {$this->newFileLocation} already exists.";
			return FALSE;
		endif;
		// Attempt to move/upload the file 
		if (!move_uploaded_file($this->tempPath, $this->newFileLocation)):
			// File was not moved - failure.
			$this->error = "The file upload failed.";
			return FALSE;
		endif;
		// SUCCESS
		return TRUE;
	}
981441
def save_file(self):
        """"""

        l = []
        walk = self.walker
        for edit in walk.lines:
            # collect the text already stored in edit widgets
            if edit.original_text.expandtabs() == edit.edit_text:
                l.append(edit.original_text)
            else:
                l.append(re_tab(edit.edit_text))

        # then the rest
        while walk.file is not None:
            l.append(walk.read_next_line())

        # write back to disk
        outfile = open(self.save_name, "w")

        l_iter = iter(l)

        line = next(l_iter)
        prefix = ""

        while True:
            try:
                outfile.write(prefix + line)
                prefix = "\n"
                line = next(l_iter)
            except StopIteration:
                if line != "\n":
                    outfile.write("\n")
                break
333272
def put_file(self, filename, index, doc_type, id=None, name=None):
        
        if id is None:
            request_method = 'POST'
        else:
            request_method = 'PUT'
        path = make_path(index, doc_type, id)
        doc = file_to_attachment(filename)
        if name:
            doc["_name"] = name
        return self._send_request(request_method, path, doc)
96248
function save()
    {
        $file = $this->_getFilePath();

        $data = $this->data;
        $data = $this->getDataInterchange()->makeForward($data);
        $dataStr = "<?php\n". "return " . var_export($data, true) . ";\n";

        ErrorStack::handleError(E_ALL);
        ##  \\\\\
        ### check for directory tree
        $dirPath = dirname($file);
        if (! file_exists($dirPath) )
            if ( false === mkdir($dirPath, 0777, true) )
                throw new \RuntimeException(sprintf('Cant create store directory on (%s).', $dirPath));

        file_put_contents($file, $dataStr, LOCK_EX);
        ##  /////
        if ($exception = ErrorStack::handleDone())
            throw $exception;

        $this->_setState(self::$STATE_OK);
        return $this;
    }
381306
public function save($dest='./')
  {
    $new_name = false;
    if ( substr($dest,-1) === '/' ){
      if ( is_dir($dest) ){
        $new_name = 0;
      }
    }
    else if ( is_dir($dest) ){
      $dest .= '/';
      $new_name = 0;
    }
    else if ( is_dir(substr($dest,0,strrpos($dest,'/'))) ){
      $new_name = 1;
    }
    if ( $new_name !== false ){
      if ( $new_name === 0 ){
        $dest .= $this->name;
      }
      if ( null !== $_FILES ){
        move_uploaded_file($this->file,$dest);
        $this->file = $dest;
        $this->uploaded = 1;
      }
      else{
        copy($this->file, $dest);
      }
    }
    return $this;
  }
284373
def response_change(self, request, obj):
        
        r = super(FileAdmin, self).response_change(request, obj)
        if 'Location' in r and r['Location']:
            # it was a successful save
            if (r['Location'] in ['../'] or
                    r['Location'] == self._get_post_url(obj)):
                # this means it was a save: redirect to the directory view
                if obj.folder:
                    url = reverse('admin:filer-directory_listing',
                                  kwargs={'folder_id': obj.folder.id})
                else:
                    url = reverse(
                        'admin:filer-directory_listing-unfiled_images')
                url = "%s%s%s" % (url, popup_param(request),
                                  selectfolder_param(request, "&"))
                return HttpResponseRedirect(url)
            else:
                # this means it probably was a save_and_continue_editing
                pass
        else:
            # this means it was a save: redirect to the directory view
            if obj.folder:
                url = reverse('admin:filer-directory_listing',
                              kwargs={'folder_id': obj.folder.id})
            else:
                url = reverse(
                    'admin:filer-directory_listing-unfiled_images')
            url = "%s%s%s" % (url, popup_param(request),
                              selectfolder_param(request, "&"))
            return HttpResponseRedirect(url)

        return r
343447
def save(self, name, data, location='local', kind='json'):
        """"""
        file_ext = '.json' if kind == 'json' else '.pkl'
        path = self._get_path(name, location, file_ext=file_ext)
        _ensure_dir_exists(op.dirname(path))
        logger.debug("Save data to `%s`.", path)
        if kind == 'json':
            _save_json(path, data)
        else:
            _save_pickle(path, data)
62181
def upload_file(client, bucket, local_path, remote_path, overwrite=False):
    """"""
    bucket = client.get_bucket(bucket)
    blob = storage.Blob(remote_path, bucket)
    if (not overwrite) and blob.exists():
        raise Conflict('File/object already exists on the bucket!')
    blob.upload_from_filename(local_path)
222873
def update_media_file(upload_file):
    '''
    
    '''
    temp_directory = tempfile.mkdtemp()
    temp_file = tempfile.TemporaryFile()
    # assumes the zip file contains a directory called media
    temp_media_file = os.path.join(temp_directory, 'media')
    try:
        for chunk in upload_file.chunks():
            temp_file.write(chunk)

        with zipfile.ZipFile(temp_file, 'r') as z:
            z.extractall(temp_directory)

        if os.path.exists(temp_media_file):
            return distutils.dir_util.copy_tree(
                temp_media_file,
                settings.MEDIA_ROOT)
        else:
            raise Exception("Error: There is no directory called "
                            "'media' in the root of the zipped file")
    except Exception as e:
        raise e
    finally:
        temp_file.close()
        if os.path.exists(temp_directory):
            shutil.rmtree(temp_directory)