上传，  一般，上传页面如果是input,原生file文件框, 如： <input type="file" id="test-image-file" name="test" accept="image/gif">，像这样的，定位到该元素，然后使用 send_keys 上传的文件的绝对路径        
        @param file_name: 文件名(文件必须存在在工程resource目录下)
764838
def UploadType(cls, file_path):
        
        if not os.path.isabs(file_path):
            return False
        
        if os.path.isfile(file_path):
            cls.SendKeys(file_path)
        else:            
            return False
1220939
public boolean upload(String path, String fileName, File file) {
		try (InputStream in = FileUtil.getInputStream(file)) {
			return upload(path, fileName, in);
		} catch (IOException e) {
			throw new FtpException(e);
		}
	}
809391
def copy_file(file_name):
	

	remote_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name)
	current_path = join(getcwd(), file_name)

	try:
		copyfile(remote_file_path, current_path)
	except Exception, e:
		raise e
85902
public static function saveImage($table_name, $field_name, $file_name, $row_id=null, $extension=null) {
		return FileController::saveImage($table_name, $field_name, $file_name, $row_id, $extension);
	}
672435
function addFile(file) {
                var $li = $('<li id="' + file.id + '">' +
                        '<p class="title">' + file.name + '</p>' +
                        '<p class="imgWrap"></p>' +
                        '<p class="progress"><span></span></p>' +
                        '</li>'),

                    $btns = $('<div class="file-panel">' +
                        '<span class="cancel">' + lang.uploadDelete + '</span>' +
                        '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
                        '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
                    $prgress = $li.find('p.progress span'),
                    $wrap = $li.find('p.imgWrap'),
                    $info = $('<p class="error"></p>').hide().appendTo($li),

                    showError = function (code) {
                        switch (code) {
                            case 'exceed_size':
                                text = lang.errorExceedSize;
                                break;
                            case 'interrupt':
                                text = lang.errorInterrupt;
                                break;
                            case 'http':
                                text = lang.errorHttp;
                                break;
                            case 'not_allow_type':
                                text = lang.errorFileType;
                                break;
                            default:
                                text = lang.errorUploadRetry;
                                break;
                        }
                        $info.text(text).show();
                    };

                if (file.getStatus() === 'invalid') {
                    showError(file.statusText);
                } else {
                    $wrap.text(lang.uploadPreview);
                    if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|'+file.ext.toLowerCase()+'|') == -1) {
                        $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
                            '<span class="file-title">' + file.name + '</span>');
                    } else {
                        if (browser.ie && browser.version <= 7) {
                            $wrap.text(lang.uploadNoPreview);
                        } else {
                            uploader.makeThumb(file, function (error, src) {
                                if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
                                    $wrap.text(lang.uploadNoPreview);
                                } else {
                                    var $img = $('<img src="' + src + '">');
                                    $wrap.empty().append($img);
                                    $img.on('error', function () {
                                        $wrap.text(lang.uploadNoPreview);
                                    });
                                }
                            }, thumbnailWidth, thumbnailHeight);
                        }
                    }
                    percentages[ file.id ] = [ file.size, 0 ];
                    file.rotation = 0;

                    /* 检查文件格式 */
                    if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
                        showError('not_allow_type');
                        uploader.removeFile(file);
                    }
                }

                file.on('statuschange', function (cur, prev) {
                    if (prev === 'progress') {
                        $prgress.hide().width(0);
                    } else if (prev === 'queued') {
                        $li.off('mouseenter mouseleave');
                        $btns.remove();
                    }
                    // 成功
                    if (cur === 'error' || cur === 'invalid') {
                        showError(file.statusText);
                        percentages[ file.id ][ 1 ] = 1;
                    } else if (cur === 'interrupt') {
                        showError('interrupt');
                    } else if (cur === 'queued') {
                        percentages[ file.id ][ 1 ] = 0;
                    } else if (cur === 'progress') {
                        $info.hide();
                        $prgress.css('display', 'block');
                    } else if (cur === 'complete') {
                    }

                    $li.removeClass('state-' + prev).addClass('state-' + cur);
                });

                $li.on('mouseenter', function () {
                    $btns.stop().animate({height: 30});
                });
                $li.on('mouseleave', function () {
                    $btns.stop().animate({height: 0});
                });

                $btns.on('click', 'span', function () {
                    var index = $(this).index(),
                        deg;

                    switch (index) {
                        case 0:
                            uploader.removeFile(file);
                            return;
                        case 1:
                            file.rotation += 90;
                            break;
                        case 2:
                            file.rotation -= 90;
                            break;
                    }

                    if (supportTransition) {
                        deg = 'rotate(' + file.rotation + 'deg)';
                        $wrap.css({
                            '-webkit-transform': deg,
                            '-mos-transform': deg,
                            '-o-transform': deg,
                            'transform': deg
                        });
                    } else {
                        $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
                    }

                });

                $li.insertBefore($filePickerBlock);
            }
322892
async def send_file(self, file_type, method, file, payload) -> Union[Dict, base.Boolean]:
        
        if file is None:
            files = {}
        elif isinstance(file, str):
            # You can use file ID or URL in the most of requests
            payload[file_type] = file
            files = None
        else:
            files = {file_type: file}

        return await self.request(method, payload, files)
735921
private void putFile(String name, UploadFile uploadFile) {
		UploadFile[] fileUploads = requestFiles.get(name);
		fileUploads = fileUploads == null ? new UploadFile[] { uploadFile } : ArrayUtil.append(fileUploads, uploadFile);
		requestFiles.put(name, fileUploads);
	}
1163385
def get_file(self, file_key):
		'''
		'''
		uri = '/'.join([
						self.api_uri,
						self.files_suffix,
						file_key
						])

		return self._req('get', uri)
900260
def Upload(cls, filename):
        
        raise Exception("to do")
    
        TOOLS_PATH = ""
        RESOURCE_PATH = ""
        tool_4path = os.path.join(TOOLS_PATH, "upload.exe")        
        file_4path = os.path.join(RESOURCE_PATH, filename)
        #file_4path.decode('utf-8').encode('gbk')
        
        if os.path.isfile(file_4path):
            cls.Click()
            os.system(tool_4path + ' ' + file_4path)
        else:
            raise Exception('%s is not exists' % file_4path)
385684
def write(file_name)
      # Encode json string:
      str = JSON.pretty_generate(@dictionary)
      # Create directory if needed:
      unless File.directory?(File.dirname(file_name))
        require 'fileutils'
        FileUtils.mkdir_p(File.dirname(file_name))
      end
      # Write to file:
      File.open(file_name, 'w') {|f| f.write(str) }
    end
527041
def upload(self, image, name=None):
        
        assert self.client_id, "imgur client ID is not set! Export the IMGUR_CLIENT_ID environment variable..."
        assert self.client_secret, "imgur client secret is not set! Export the IMGUR_CLIENT_SECRET environment variable..."

        # Prepare image
        try:
            image_data = (image + '')
        except (TypeError, ValueError):
            assert hasattr(image, "read"), "Image is neither a string nor an open file handle"
            image_type = "file"
            image_data = image  # XXX are streams supported? need a temp file?
            image_repr = repr(image)
        else:
            if image.startswith("http:") or image.startswith("https:"):
                image_type = "url"
                image_data = image
                image_repr = image
            elif all(ord(i) >= 32 for i in image) and os.path.exists(image):
                image_type = "file"
                image_data = image  # XXX open(image, "rb")
                image_repr = "file:" + image
            else:
                # XXX Not supported anymore (maybe use a temp file?)
                image_type = "base64"
                image_data = image_data.encode(image_type)
                image_repr = "<binary data>"

        # Upload image
        # XXX "name",    name or hashlib.md5(str(image)).hexdigest()),
        client = ImgurClient(self.client_id, self.client_secret)
        result = (client.upload_from_url if image_type == 'url'
                  else client.upload_from_path)(image_data)  # XXX config=None, anon=True)

        if result['link'].startswith('http:'):
            result['link'] = 'https:' + result['link'][5:]
        result['hash'] = result['id']  # compatibility to API v1
        result['caption'] = result['description']  # compatibility to API v1

        return parts.Bunch(
            image=parts.Bunch(result),
            links=parts.Bunch(
                delete_page=None,
                imgur_page=None,
                original=result['link'],
                large_thumbnail="{0}s.{1}".format(*result['link'].rsplit('.', 1)),
                small_square="{0}l.{1}".format(*result['link'].rsplit('.', 1)),
            ))
46147
def _get_file_event_handler(self, file_path, save_name):
        
        self._file_pusher.update_file(save_name, file_path)  # track upload progress

        if save_name not in self._file_event_handlers:
            if save_name == 'wandb-history.jsonl':
                self._file_event_handlers['wandb-history.jsonl'] = FileEventHandlerTextStream(
                    file_path, 'wandb-history.jsonl', self._api)
            elif save_name == 'wandb-events.jsonl':
                self._file_event_handlers['wandb-events.jsonl'] = FileEventHandlerTextStream(
                    file_path, 'wandb-events.jsonl', self._api)
            elif 'tfevents' in save_name or 'graph.pbtxt' in save_name:
                # overwrite the tensorboard but not every reload -- just
                # frequently enough to resemble realtime
                self._file_event_handlers[save_name] = FileEventHandlerThrottledOverwrite(
                    file_path, save_name, self._api, self._file_pusher)
            # Don't try to stream tensorboard files for now.
            # elif 'tfevents' in save_name:
            #    # TODO: This is hard-coded, but we want to give users control
            #    # over streaming files (or detect them).
            #    self._api.get_file_stream_api().set_file_policy(save_name,
            #                                                    BinaryFilePolicy())
            #    self._file_event_handlers[save_name] = FileEventHandlerBinaryStream(
            #        file_path, save_name, self._api)
            # Overwrite handler (non-deferred) has a bug, wherein if the file is truncated
            # during upload, the request to Google hangs (at least, this is my working
            # theory). So for now we defer uploading everything til the end of the run.
            # TODO: send wandb-summary during run. One option is to copy to a temporary
            # file before uploading.
            elif save_name == config.FNAME:
                self._file_event_handlers[save_name] = FileEventHandlerConfig(
                    file_path, save_name, self._api, self._file_pusher, self._run)
            elif save_name == 'wandb-summary.json':
                # Load the summary into the syncer process for meta etc to work
                self._run.summary.load()
                self._api.get_file_stream_api().set_file_policy(save_name, OverwriteFilePolicy())
                self._file_event_handlers[save_name] = FileEventHandlerSummary(
                    file_path, save_name, self._api, self._file_pusher, self._run)
            elif save_name.startswith('media/'):
                # Save media files immediately
                self._file_event_handlers[save_name] = FileEventHandlerOverwrite(
                    file_path, save_name, self._api, self._file_pusher)
            else:
                Handler = FileEventHandlerOverwriteDeferred
                for policy, globs in six.iteritems(self._user_file_policies):
                    if policy == "end":
                        continue
                    for g in globs:
                        if any(save_name in p for p in glob.glob(os.path.join(self._run.dir, g))):
                            if policy == "live":
                                Handler = FileEventHandlerThrottledOverwriteMinWait
                self._file_event_handlers[save_name] = Handler(
                    file_path, save_name, self._api, self._file_pusher)
        return self._file_event_handlers[save_name]
55305
function (fieldname, file, filename) {
          const acceptedExtensions = strapi.api.upload.config.acceptedExtensions || [];
          if (acceptedExtensions[0] !== '*' && !_.contains(acceptedExtensions, path.extname(filename))) {
            this.status = 400;
            this.body = {
              message: 'Invalid file format ' + filename ? 'for this file' + filename : ''
            };
          }
        }
191802
public static function upload($form_name = 'file', $data = [])
    {
        $settings = \Yii::$app->settings;
        if (!empty($data['quality'])) {
            $quality = $data['quality'];
        } else {
            $quality = Media::getConfigurationQuality(50);
        }
        $file = UploadedFile::getInstanceByName($form_name);
        if ($file) {
            $file->name = str_replace([' ', '(', ')'], '-', trim(addslashes($file->name)));
            $uploadDir = self::getUploadDir();
            FileHelper::createDirectory(self::getUploadDir() . '/' . date('Y/m/d'));
            $fileName = date('Y/m/d') . '/' . date('his') . '-' . $file->name;
            $fileName_save = $uploadDir . '/' . $fileName;
            $file->saveAs($fileName_save);
            Image::getImagine()->open($fileName_save)->save($fileName_save, ['quality' => $quality]);
            $url = 'uploads/' . $fileName;

            $media = new Media([
                'name' => $file->name,
                'path' => $url,
                'type' => FileHelper::getMimeType($fileName_save),
                'file_size' => filesize($fileName_save),
                'dimensions' => getimagesize($fileName_save)[0] . 'x' . getimagesize($fileName_save)[1],
            ]);
            if (!empty($data['title'])) {
                $media->title = $data['title'];
            }
            if (!empty($data['caption'])) {
                $media->caption = $data['caption'];
            }
            if (!empty($data['alt'])) {
                $media->alt = $data['alt'];
            }
            if (!empty($data['description'])) {
                $media->description = $data['description'];
            }
            if (!\Yii::$app->user->isGuest) {
                $media->created_by = \Yii::$app->user->id;
            }
            $media->save();

            /**
             * Generate All Other size
             */
            if (empty($thumbnailDir)) {
                $thumbnailDir = \Yii::getAlias('@thumbnail');
            }
            FileHelper::createDirectory($thumbnailDir . '/' . date('Y/m/d'));
            $thumbnail_save = $thumbnailDir . '/' . $fileName;
            $thumbnail_size_width = Media::getConfigurationThumbnailSizeWidth();
            $thumbnail_size_height = Media::getConfigurationThumbnailSizeHeight();
            Image::getImagine()->open($fileName_save)->thumbnail(new Box($thumbnail_size_width, $thumbnail_size_height))->save($thumbnail_save , ['quality' => $quality]);
            if (empty($mediumDir)) {
                $mediumDir = \Yii::getAlias('@medium');
            }
            FileHelper::createDirectory($mediumDir. '/' . date('Y/m/d'));
            $medium_save = $mediumDir . '/' . $fileName;
            $medium_size_width = Media::getConfigurationMediumSizeWidth();
            $medium_size_height = Media::getConfigurationMediumSizeHeight();
            Image::getImagine()->open($fileName_save)->thumbnail(new Box($medium_size_width, $medium_size_height))->save($medium_save , ['quality' => $quality]);
            if (empty($largeDir)) {
                $largeDir = \Yii::getAlias('@large');
            }
            FileHelper::createDirectory($largeDir . '/' . date('Y/m/d'));
            $large_save = $largeDir  . '/' . $fileName;
            $large_size_width = Media::getConfigurationLargeSizeWidth();
            $large_size_height = Media::getConfigurationLargeSizeHeight();
            Image::getImagine()->open($fileName_save)->thumbnail(new Box($large_size_width, $large_size_height))->save($large_save , ['quality' => $quality]);
            return $url;
        } else {
            return null;
        }
    }
1146381
def file_upload(self, folder_id: str, file_name: str, mine_type: str) -> bool:
        
        service = self.__get_service()
        media_body = MediaFileUpload(file_name, mimetype=mine_type, resumable=True)
        body = {
            'name': os.path.split(file_name)[-1],
            'mimeType': "text/csv",
            'parents': [folder_id],
        }
        return service.files().create(body=body, media_body=media_body).execute()
1015273
def _get_simple_uploaded_file(self, image, file_name):
        
        extension = os.path.splitext(file_name)[1]

        mimetype, encoding = mimetypes.guess_type(file_name)
        content_type = mimetype or 'image/png'

        temp_handle = BytesIO()
        image.save(temp_handle, self._get_pil_format(extension))
        temp_handle.seek(0)  # rewind the file

        suf = SimpleUploadedFile(
            file_name,
            temp_handle.read(),
            content_type=content_type,
        )
        return suf
220939
def upload_file(self, file_name, file_obj, *args, **kwargs):
		
		self.dav_client().upload_to(file_obj, self.join_path(self.session_path(), file_name))