Beispiel #1
0
 public static void Log(UploadedFile file, string uploadId)
 {
 }
Beispiel #2
0
        public Stream GetOutputStream(UploadedFile file)
        {
            FileUploadStreamProvider.FileNameMethod fileNameMethod = this._fileNameMethod;
            string clientName;

            if (fileNameMethod != FileUploadStreamProvider.FileNameMethod.Guid)
            {
                if (fileNameMethod != FileUploadStreamProvider.FileNameMethod.Custom)
                {
                    clientName = file.ClientName;
                }
                else
                {
                    clientName = this._fileNameGenerator.GenerateFileName(file);
                    bool flag = clientName.StartsWith("~");
                    if (flag)
                    {
                        clientName = HttpContext.Current.Server.MapPath(clientName);
                    }
                }
            }
            else
            {
                clientName = Guid.NewGuid().ToString("n");
            }
            bool flag2 = !Path.IsPathRooted(clientName);

            if (flag2)
            {
                clientName = Path.Combine(this._location, clientName);
            }
            string directoryName = Path.GetDirectoryName(clientName);
            bool   flag3         = !Directory.Exists(directoryName);

            if (flag3)
            {
                Directory.CreateDirectory(directoryName);
            }
            file.LocationInfo["fileName"] = clientName;
            Stream stream = null;
            Stream stream2;

            try
            {
                switch (this._existingAction)
                {
                case FileUploadStreamProvider.ExistingAction.Overwrite:
                    stream = new FileStream(clientName, FileMode.Create);
                    break;

                case FileUploadStreamProvider.ExistingAction.Exception:
                    stream = new FileStream(clientName, FileMode.CreateNew);
                    break;

                case FileUploadStreamProvider.ExistingAction.Rename:
                {
                    string fileName = Path.GetFileName(clientName);
                    int    index    = fileName.IndexOf('.');
                    bool   flag4    = index == -1;
                    string text4;
                    string text5;
                    if (flag4)
                    {
                        text4 = clientName;
                        text5 = string.Empty;
                    }
                    else
                    {
                        text4 = Path.Combine(Path.GetDirectoryName(clientName), fileName.Substring(0, index));
                        text5 = fileName.Substring(index);
                    }
                    int num2 = 0;
                    do
                    {
                        num2++;
                        clientName = string.Concat(new string[]
                            {
                                text4,
                                "[",
                                num2.ToString(),
                                "]",
                                text5
                            });
                        bool flag5 = !File.Exists(clientName);
                        if (flag5)
                        {
                            file.LocationInfo["fileName"] = clientName;
                            try
                            {
                                stream = new FileStream(clientName, FileMode.CreateNew);
                            }
                            catch
                            {
                            }
                        }
                    }while (stream == null);
                    break;
                }
                }
                stream2 = stream;
            }
            catch
            {
                bool flag6 = stream != null;
                if (flag6)
                {
                    stream.Close();
                    this.RemoveOutput(file);
                }
                file.LocationInfo.Clear();
                throw;
            }
            return(stream2);
        }
Beispiel #3
0
 public Stream GetInputStream(UploadedFile file)
 {
     return(new SqlClientOutputStream(this._connectionString, this._tablename, this._dataField, file.LocationInfo["whereCriteria"]));
 }
Beispiel #4
0
 public Stream GetInputStream(UploadedFile file)
 {
     return(File.OpenRead(file.LocationInfo["fileName"]));
 }