Ejemplo n.º 1
0
        /// <summary>
        ///     上传文件数据流,根据文件大小以及设置的阈值(用户初始化UploadManager时可指定该值)自动选择:
        ///     若文件大小超过设定阈值,使用ResumableUploader,否则使用FormUploader
        /// </summary>
        /// <param name="stream">待上传的数据流</param>
        /// <param name="key">要保存的文件名称</param>
        /// <param name="token">上传凭证</param>
        /// <param name="extra">上传可选设置</param>
        /// <returns>上传文件后的返回结果</returns>
        public Task <HttpResult> UploadStream(Stream stream, string key, string token, PutExtra extra)
        {
            if (stream.Length > _config.PutThreshold)
            {
                var resumeUploader = new ResumableUploader(_config);
                return(resumeUploader.UploadStream(stream, key, token, extra));
            }

            var formUploader = new FormUploader(_config);

            return(formUploader.UploadStream(stream, key, token, extra));
        }
Ejemplo n.º 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 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));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 上传文件数据流,根据文件大小以及设置的阈值(用户初始化UploadManager时可指定该值)自动选择:
        /// 若文件大小超过设定阈值,使用ResumableUploader,否则使用FormUploader
        /// </summary>
        /// <param name="stream">待上传的数据流</param>
        /// <param name="key">要保存的文件名称</param>
        /// <param name="token">上传凭证</param>
        /// <param name="extra">上传可选设置</param>
        /// <returns>上传文件后的返回结果</returns>
        public HttpResult UploadStream(Stream stream, string key, string token, PutExtra extra)
        {
            HttpResult result = new HttpResult();

            if (stream.Length > this.config.PutThreshold)
            {
                ResumableUploader resumeUploader = new ResumableUploader(this.config);
                result = resumeUploader.UploadStream(stream, key, token, extra);
            }
            else
            {
                FormUploader formUploader = new FormUploader(this.config);
                result = formUploader.UploadStream(stream, key, token, extra);
            }

            return(result);
        }
Ejemplo n.º 4
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);
        }