public UploadStreamProvider(IUploadStream uploadStream)
 {
     _uploadStream = uploadStream ?? throw new ArgumentNullException(nameof(uploadStream));
     FormData      = new NameValueCollection();
     FileData      = new Collection <MultipartFileData>();
     _isFormData   = new Collection <bool>();
 }
        public Task <UploadStreamProvider> Upload(IUploadStream uploadStream)
        {
            if (!_request.Content.IsMimeMultipartContent("form-data"))
            {
                throw new InvalidOperationException("UnsupportedMediaType");
            }

            UploadStreamProvider provider = new UploadStreamProvider(uploadStream);

            return(_request.Content.ReadAsMultipartAsync(provider));
        }
Esempio n. 3
0
        protected override UploadStreamProvider InstanceFactory()
        {
            IUploadStream uploadStream = A.Fake <IUploadStream>();

            return(new UploadStreamProvider(uploadStream));
        }
 public Task <UploadFileResults> GetResults(IUploadStream uploadStream)
 {
     return(Upload(uploadStream).ContinueWith(x => new UploadFileResults(x.Result)));
 }