예제 #1
0
        public virtual UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
		                                                  string contentType, UploadStorageConfig storageConfig)
        {
            if (storageConfig != null && storageConfig.Count != 0)
              	{
              		throw new ApplicationException(this.Name + " doesn't understand InputFile.StorageConfig.");
              	}
              	return this.CreateUploadedFile(context, controlUniqueID, fileName, contentType);
        }
예제 #2
0
 public virtual UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
                                                string contentType, UploadStorageConfig storageConfig)
 {
     if (storageConfig != null && storageConfig.Count != 0)
     {
         throw new ApplicationException(this.Name + " doesn't understand InputFile.StorageConfig.");
     }
     return(this.CreateUploadedFile(context, controlUniqueID, fileName, contentType));
 }
예제 #3
0
        public static UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
                                                      string contentType, UploadStorageConfig storageConfig)
        {
            UploadedFile file = null;

            if (storageConfig == null || storageConfig.Count == 0)
            {
                file = Provider.CreateUploadedFile(context, controlUniqueID, fileName, contentType);
            }
            else
            {
                file = Provider.CreateUploadedFile(context, controlUniqueID, fileName, contentType, storageConfig);
            }
            return(file);
        }
예제 #4
0
        public static UploadedFile ConvertToUploadedFile(string controlUniqueID, HttpPostedFile file)
        {
            // We use a temporary UploadContext so that we have something we can pass to the
            // UploadStorageProvider.  Note that unlike when the UploadHttpModule is used,
            // this temporary context is not shared between uploaded files.
            UploadContext ctx = new UploadContext();

            ctx._ContentLength = HttpContext.Current.Request.ContentLength;
            UploadStorageConfig storageConfig = UploadStorage.CreateUploadStorageConfig();
            string storageConfigString
                = HttpContext.Current.Request.Form[Constants.ConfigNamePrefix + "-" + controlUniqueID];

            if (storageConfigString != null && storageConfigString != string.Empty)
            {
                storageConfig.Unprotect(storageConfigString);
            }
            UploadedFile uploadedFile
                = UploadStorage.CreateUploadedFile(ctx, controlUniqueID, file.FileName, file.ContentType, storageConfig);

            System.IO.Stream outStream = null, inStream = null;
            try
            {
                outStream = uploadedFile.CreateStream();
                inStream  = file.InputStream;
                byte[] buf       = new byte[4096];
                int    bytesRead = -1;
                while (outStream.CanWrite && inStream.CanRead &&
                       (bytesRead = inStream.Read(buf, 0, buf.Length)) > 0)
                {
                    outStream.Write(buf, 0, bytesRead);
                }
            }
            finally
            {
                if (inStream != null)
                {
                    inStream.Close();
                }
                if (outStream != null)
                {
                    outStream.Close();
                }
            }
            return(uploadedFile);
        }
예제 #5
0
 public override UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName, string contentType, UploadStorageConfig storageConfig)
 {
     return(new FilesystemUploadedFile(this, controlUniqueID, fileName, contentType, storageConfig));
 }
예제 #6
0
 public override UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName, string contentType)
 {
     return(this.CreateUploadedFile(context, controlUniqueID, fileName, contentType, null));
 }
예제 #7
0
 public override UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName, string contentType)
 {
     return(new HashingFilesystemUploadedFile(this, controlUniqueID, fileName, contentType));
 }
 public override UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName, string contentType, UploadStorageConfig storageConfig)
 {
     return new FilesystemUploadedFile(this, controlUniqueID, fileName, contentType, storageConfig);
 }
 public override UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName, string contentType)
 {
     return this.CreateUploadedFile(context, controlUniqueID, fileName, contentType, null);
 }
예제 #10
0
 public static UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
                                               string contentType)
 {
     return(CreateUploadedFile(context, controlUniqueID, fileName, contentType, null));
 }
예제 #11
0
        public static UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
		                                              string contentType, UploadStorageConfig storageConfig)
        {
            UploadedFile file = null;
            if (storageConfig == null || storageConfig.Count == 0)
            {
                file = Provider.CreateUploadedFile(context, controlUniqueID, fileName, contentType);
            }
            else
            {
                file = Provider.CreateUploadedFile(context, controlUniqueID, fileName, contentType, storageConfig);
            }
            return file;
        }
예제 #12
0
        public static UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
		                                              string contentType)
        {
            return CreateUploadedFile(context, controlUniqueID, fileName, contentType, null);
        }
 public override UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName, string contentType)
 {
     return new HashingFilesystemUploadedFile(this, controlUniqueID, fileName, contentType);
 }
예제 #14
0
 UploadedFile IUploadModule.ConvertToUploadedFile(string controlUniqueID, HttpPostedFile file)
 {
     // We use a temporary UploadContext so that we have something we can pass to the
     // UploadStorageProvider.  Note that unlike when the UploadHttpModule is used,
     // this temporary context is not shared between uploaded files.
     UploadContext ctx = new UploadContext();
     ctx._ContentLength = HttpContext.Current.Request.ContentLength;
     UploadStorageConfig storageConfig = UploadStorage.CreateUploadStorageConfig();
     string storageConfigString
         = HttpContext.Current.Request.Form[Constants.ConfigNamePrefix + "-" + controlUniqueID];
     if (storageConfigString != null && storageConfigString != string.Empty)
     {
         storageConfig.Unprotect(storageConfigString);
     }
     UploadedFile uploadedFile
         = UploadStorage.CreateUploadedFile(ctx, controlUniqueID, file.FileName, file.ContentType, storageConfig);
     System.IO.Stream outStream = null, inStream = null;
     try
     {
         outStream = uploadedFile.CreateStream();
         inStream = file.InputStream;
         byte[] buf = new byte[4096];
         int bytesRead = -1;
         while (outStream.CanWrite && inStream.CanRead
                && (bytesRead = inStream.Read(buf, 0, buf.Length)) > 0)
         {
             outStream.Write(buf, 0, bytesRead);
         }
     }
     finally
     {
         if (inStream != null) inStream.Close();
         if (outStream != null) outStream.Close();
     }
     return uploadedFile;
 }