SQL Server Uploader
=============================
This file contains some notes about how this plug-in to NeatUpload works. To understand this plug-in you probably should have tried NeatUpload first.
This plug-in can either generate SQL itself and use against the server or use stored procedures on the server for all tasks. An example of how those stored procedures
could look is supplied at the end of this document.
This plugin is written by Joakim Wennergren (jokedst@gmail.com). Feel free to contact me with any questions, or post them at the NeatUpload forum (www.bretle.com).
This plugin is release under the GNU Lesser General Public License. See the disclaimer in the source code files for more information.
===============
USAGE
===============
To specify whether this plug-in should generate SQL queries or use stored procedures, you configure the "provider" in web.config. If you specify procedure names
(createProcedure, openProcedure, readProcedure, writeProcedure, deleteProcedure, cleanupProcedure, renameProcedure, storeHashProcedure) the code uses the procedures.
If you instead specify table and column names (tableName, dataColumnName, partialFlagColumnName, fileNameColumnName, mimeTypeColumnName, hashColumnName) the code
will build its own SQL Queries. You can also combine both methods, if procedures are named they have precedence.
There is also the setting "hashAlgorithm". If specified, the uploader will calculate a hash value of the uploaded file while it is uploaded. The code is mainly
copied from Dean's HashingFilesystemUploadStorageProvider plug-in. The Hash algorithm may be any supported by the .NET framework, including the common MD5, SHA1 and SHA256.
Note that to specify connectionstring this plug-in supports using the ConectionStrings-section in web.config under .NET v2.0. To use a named connectionstring, enter the
name of the connection string instead of the string itself (see included web.config).
The examples in this project use a database table that looks like this:
CREATE TABLE [FileTable] (
[Id] [int] IDENTITY (1, 1) PRIMARY KEY NOT NULL ,
[FileName] [nvarchar] (50) NULL,
[DataField] [image] NOT NULL ,
[Partial] [tinyint] NOT NULL ,
[MimeType] [nvarchar] (50) NULL ,
[Created] [datetime] NOT NULL CONSTRAINT [DF_FileTable_Created] DEFAULT (getdate()),
[FileHash] [nvarchar] (50) NULL ,
)
The only necessary fields for the uploader to work are an IDENTITY field and a Image/varbinary field for the data, the others are optional.
Change the connection strings in the web.config to point to your database and the right table
Note that the version that uses generated SQL (as opposed to stored procedures) only works on SQL 2005 because it makes heavy use of the "$IDENTITY" object
to reference the IDENTITY column of the table. To fix this I should add a "IdentityColumnName"-setting, but since I only use SQL 2005 (and stored procedures)
it has never been an issue... Use stored procedures to get around this problem if you don't want to rewrite these classes and must use SQL Server 2000.
When using NeatUpload you get a bunch of warnings about the web.config file since the NeatUpload-addons to the system.web section isn't in Microsoft's .xsd-schema for
web.config. This is nothing to worry about, but if you find the warnings annoying, add this to C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas\DotNetConfig.xsd
to get rid of them. It should be placed in the "choice" section under the element "configuration/system.web"
<xs:element name="neatUpload" vs:help="configuration/system.web/neatUpload">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="providers" vs:help="configuration/system.web/neatUpload/providers">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="add" vs:help="configuration/system.web/httpHandlers/add">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="type" type="xs:string" use="required" />
<xs:attribute name="tempDirectory" type="xs:string" use="optional" />
<!-- HashingFilesystemUploadStorageProvider specific -->
<xs:attribute name="algorithm" type="xs:string" use="optional" />
<!-- SqlServerUploader specific -->
<xs:attribute name="connectionString" type="xs:string" use="optional" />
<xs:attribute name="connectionName" type="xs:string" use="optional" />
<xs:attribute name="tableName" type="xs:string" use="optional" />
<xs:attribute name="dataColumnName" type="xs:string" use="optional" />
<xs:attribute name="partialFlagColumnName" type="xs:string" use="optional" />
<xs:attribute name="fileNameColumnName" type="xs:string" use="optional" />
<xs:attribute name="mimeTypeColumnName" type="xs:string" use="optional" />
<xs:attribute name="hashAlgorithm" type="xs:string" use="optional" />
<xs:attribute name="hashColumnName" type="xs:string" use="optional" />
<xs:attribute name="createProcedure" type="xs:string" use="optional" />
<xs:attribute name="openProcedure" type="xs:string" use="optional" />
<xs:attribute name="writeProcedure" type="xs:string" use="optional" />
<xs:attribute name="readProcedure" type="xs:string" use="optional" />
<xs:attribute name="cleanupProcedure" type="xs:string" use="optional" />
<xs:attribute name="renameProcedure" type="xs:string" use="optional" />
<xs:attribute name="storeHashProcedure" type="xs:string" use="optional" />
<xs:attribute name="deleteProcedure" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="defaultProvider" type="xs:string" use="optional" />
<xs:attribute name="useHttpModule" type="small_boolean_Type" use="optional" />
<xs:attribute name="maxNormalRequestLength" type="xs:int" use="optional" />
<xs:attribute name="maxRequestLength" type="xs:int" use="optional" />
<xs:attribute name="postBackIDQueryParam" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
=====================================================
Stored Procedures example
SQL Server 2005:
=====================================================
CREATE TABLE [FileTable] (
[Id] [int] IDENTITY (1, 1) PRIMARY KEY NOT NULL ,
[FileName] [nvarchar] (50) NOT NULL ,
[DataField] [image] NOT NULL ,
[Partial] [tinyint] NOT NULL ,
[MimeType] [nvarchar] (50) NOT NULL ,
[Created] [datetime] NOT NULL CONSTRAINT [DF_FileTable_Created] DEFAULT (getdate()),
[FileHash] [nvarchar] (50) NULL ,
)
GO
CREATE Procedure CreateBlob
@Identity Numeric Output,
@Pointer Binary(16) Output,
@FileName VarChar(250) = null,
@MIMEType VarChar(250) = null
As Begin Set NoCount ON;
Insert Into VerboseTable2 (Datafield,FileName,MimeType,Partial) Values ('',@FileName,@MimeType,1)
Select @Identity = SCOPE_IDENTITY()
Select @Pointer = TEXTPTR(DataField) From VerboseTable2 Where $IDENTITY = @Identity
End
Go
CREATE Procedure OpenBlob
@Identity Numeric,
@Pointer VarBinary(max) Output,
@Size Int Output,
@FileName VarChar(250) Output,
@MIMEType VarChar(250) Output
As Begin Set NoCount On
Select @Pointer = TEXTPTR(DataField),
@Size = DATALENGTH(DataField),
@FileName = [FileName],
@MIMEType = MIMEType
From VerboseTable2 Where $IDENTITY = @Identity
End
Go
CREATE Procedure ReadBlob
@Identity Numeric, --ignored in this implementation, here for reference
@Pointer Binary(16),
@Offset Int,
@Size Int
As Begin Set NoCount On
ReadText VerboseTable2.DataField @Pointer @Offset @Size
End
Go
CREATE Procedure WriteBlob
@Identity Numeric, --ignored in this imple
没有合适的资源?快使用搜索试试~ 我知道了~
ASP.NET 上传大文件NeatUpload组件源码
共435个文件
html:268个
cs:54个
gif:24个
需积分: 0 21 下载量 138 浏览量
2009-10-20
09:20:05
上传
评论
收藏 831KB ZIP 举报
温馨提示
ASP.NET 上传大文件NeatUpload组件源码 NeatUpload-1.2.30.zip
资源详情
资源评论
资源推荐
收起资源包目录
ASP.NET 上传大文件NeatUpload组件源码 (435个子文件)
Global.asax 81B
TestControl.ascx 431B
DBWrite.aspx 6KB
Demo.aspx 5KB
HashedDemo.aspx 5KB
Progress.aspx 5KB
Bugs.aspx 3KB
MultipleBars.aspx 2KB
StorageConfig.aspx 2KB
Test.aspx 2KB
HideFallback.aspx 2KB
TriggerChildren.aspx 1KB
InlineProgressBarsInOpera.aspx 1KB
Error413.aspx 304B
DBRead.aspx 102B
Web.config 2KB
Web.config 1KB
Web.config 1KB
Web.config 1KB
log4net.config 1KB
log4net.config 1KB
log4net.config 1KB
Web.config 625B
Web.config 245B
ProgressBar.cs 29KB
SqlServerBlobStream.cs 28KB
FilteringWorkerRequest.cs 20KB
InputFile.cs 15KB
SqlServerUploadStorageProvider.cs 13KB
UploadHttpModule.cs 12KB
SqlServerUploadedFile.cs 11KB
DecoratedWorkerRequest.cs 11KB
ProgressPage.cs 10KB
UploadContext.cs 9KB
Config.cs 9KB
DBWrite.aspx.cs 8KB
Main.cs 6KB
Demo.aspx.cs 5KB
UploadStorageConfig.cs 5KB
DetailsControl.cs 5KB
DBRead.aspx.cs 5KB
HashedDemo.aspx.cs 4KB
UploadStorage.cs 4KB
FilesystemUploadedFile.cs 4KB
MockWorkerRequest.cs 4KB
Progress-1.0.aspx.cs 4KB
FieldNameTranslator.cs 3KB
MultipleBars.aspx.cs 3KB
SqlServerInputFile.cs 3KB
FilesystemUploadStorageProvider.cs 3KB
FormContext.cs 2KB
UploadStorageProvider.cs 2KB
TriggerChildren.aspx.cs 2KB
FilterTester.cs 2KB
HashingFilesystemUploadedFile.cs 2KB
HashedInputFile.cs 2KB
DBWrite.aspx.designer.cs 2KB
SizeLimitingWorkerRequest.cs 2KB
UploadedFile.cs 2KB
AssemblyInfo.cs 2KB
AssemblyInfo.cs 2KB
HashingFilesystemUploadStorageProvider.cs 2KB
MyLog4net.cs 2KB
UploadStorageProviderCollection.cs 1KB
DetailsSpan.cs 1KB
DetailsDiv.cs 1KB
TestControl.ascx.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
ConfigSectionHandler.cs 1KB
MoveToOptions.cs 1KB
Global.asax.cs 1KB
UploadTooLargeException.cs 1KB
InvalidStorageConfigException.cs 1KB
UploadStatus.cs 1KB
AssemblyInfo.cs 1KB
UploadException.cs 1KB
DBRead.aspx.designer.cs 466B
NeatUpload.csproj 10KB
HashedInputFile.csproj 6KB
SqlServerUploader.csproj 5KB
UploaderTest.csproj 4KB
MSDN.css 8KB
tree.css 1006B
default.css 470B
Brettle.Web.NeatUpload.dll 91KB
Brettle.Web.NeatUpload.dll 91KB
Brettle.Web.NeatUpload.dll 91KB
Brettle.Web.NeatUpload.dll 91KB
Brettle.Web.NeatUpload.dll 91KB
Brettle.Web.NeatUpload.dll 91KB
Hitone.Web.SqlServerUploader.dll 21KB
Hitone.Web.SqlServerUploader.dll 21KB
Brettle.Web.NeatUpload.HashedInputFile.dll 7KB
Brettle.Web.NeatUpload.HashedInputFile.dll 7KB
Brettle.Web.NeatUpload.HashedInputFile.dll 7KB
TestFilter.exe 7KB
TestFilter.exe 7KB
protproperty.gif 923B
protfield.gif 914B
共 435 条
- 1
- 2
- 3
- 4
- 5
3q2008Com
- 粉丝: 1409
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0