/// <summary>
        ///     上传文件,根据文件大小以及设置的阈值(用户初始化UploadManager时可指定该值)自动选择:
        ///     若文件大小超过设定阈值,使用ResumableUploader,否则使用FormUploader
        /// </summary>
        /// <param name="localFile">本地待上传的文件名</param>
        /// <param name="key">要保存的文件名称</param>
        /// <param name="token">上传凭证</param>
        /// <param name="extra">上传可选设置</param>
        /// <returns>上传文件后的返回结果</returns>
        public Task <HttpResult> UploadFile(string localFile, string key, string token, PutExtra extra)
        {
            var fi = new System.IO.FileInfo(localFile);

            if (fi.Length > _config.PutThreshold)
            {
                var resumeUploader = new ResumableUploader(_config);
                return(resumeUploader.UploadFile(localFile, key, token, extra));
            }

            var formUploader = new FormUploader(_config);

            return(formUploader.UploadFile(localFile, key, token, extra));
        }
Beispiel #2
0
        /// <summary>
        /// 上传文件,根据文件大小以及设置的阈值(用户初始化UploadManager时可指定该值)自动选择:
        /// 若文件大小超过设定阈值,使用ResumableUploader,否则使用FormUploader
        /// </summary>
        /// <param name="localFile">本地待上传的文件名</param>
        /// <param name="key">要保存的文件名称</param>
        /// <param name="token">上传凭证</param>
        /// <param name="extra">上传可选设置</param>
        /// <returns>上传文件后的返回结果</returns>
        public HttpResult UploadFile(string localFile, string key, string token, PutExtra extra)
        {
            HttpResult result = new HttpResult();

            System.IO.FileInfo fi = new System.IO.FileInfo(localFile);
            if (fi.Length > this.config.PutThreshold)
            {
                ResumableUploader resumeUploader = new ResumableUploader(config);
                result = resumeUploader.UploadFile(localFile, key, token, extra);
            }
            else
            {
                FormUploader formUploader = new FormUploader(config);
                result = formUploader.UploadFile(localFile, key, token, extra);
            }

            return(result);
        }