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
没有合适的资源?快使用搜索试试~ 我知道了~
NeatUpload大文件上传(进度条显示)..
共1136个文件
html:709个
cs:90个
dll:55个
5星 · 超过95%的资源 需积分: 9 39 下载量 72 浏览量
2010-02-25
13:33:49
上传
评论 2
收藏 3.04MB RAR 举报
温馨提示
NeatUpload大文件上传(进度条显示)组件及演示源码 NeatUpload解决Asp.net中大文件上传的问题的组件,支持进度条显示、上传过程中取消,当前版本为1.3.21。
资源推荐
资源详情
资源评论
收起资源包目录
NeatUpload大文件上传(进度条显示).. (1136个子文件)
SWFUpload.as 24KB
FileItem.as 1KB
Delegate.as 156B
TrickyTestControl.ascx 905B
TestControl.ascx 624B
StaticUploadHandler.ashx 2KB
MultiRequestUploadHandler.ashx 89B
MultiRequestUploadHandler.ashx 89B
MultiRequestUploadHandler.ashx 89B
ProgressJsonHandler.ashx 87B
UploadStateStoreHandler.ashx 87B
UploadStateStoreHandler.ashx 87B
ProgressJsonHandler.ashx 87B
Demo.aspx 8KB
SmoothProgress.aspx 7KB
SmoothProgress.aspx 7KB
DBWrite.aspx 6KB
Progress.aspx 5KB
Progress.aspx 5KB
Progress.aspx 5KB
HashedDemo.aspx 5KB
Processing.aspx 3KB
Test.aspx 3KB
TriggerInGridViewAfterProgressBar.aspx 3KB
Bugs.aspx 3KB
Demo.aspx 2KB
MultipleBars.aspx 2KB
HtmlInputFileAfterInputFile.aspx 2KB
StorageConfig.aspx 2KB
Test.aspx 2KB
HideFallback.aspx 2KB
ClientSideForm.aspx 2KB
TriggerChildren.aspx 1KB
InlineProgressBarsInOpera.aspx 1KB
WithoutNeatUpload.aspx 934B
Transfer.aspx 366B
Error413.aspx 319B
Error413.aspx 319B
ConsoleOut.aspx 234B
DBRead.aspx 102B
PostBuild.bat 628B
Build.bat 548B
PostBuild.bat 418B
Build 286B
ResolveAssemblyReference.cache 18KB
ResolveAssemblyReference.cache 5KB
ResolveAssemblyReference.cache 5KB
ResolveAssemblyReference.cache 5KB
Brettle.Web.NeatUpload.csproj.GenerateResource.Cache 938B
Web.config 7KB
Web.config 7KB
Web.config 7KB
Web.config 3KB
Web.config 2KB
log4net.config 1KB
Web.config 697B
Web.config 282B
Web.config 282B
SqlServerBlobStream.cs 33KB
UploadHttpModule.cs 31KB
FilteringWorkerRequest.cs 28KB
UploadModule.cs 19KB
ObjectProtector.cs 19KB
DecoratedWorkerRequest.cs 17KB
Config.cs 16KB
ProgressBarBase.cs 13KB
SqlServerUploadStorageProvider.cs 13KB
SqlServerUploadedFile.cs 12KB
ProgressPage.cs 12KB
InputFile.cs 11KB
IUploadModule.cs 11KB
MultiFile.cs 11KB
UploadState.cs 10KB
MultiRequestUploadModule.cs 10KB
UploadStateStoreProvider.cs 9KB
UploadStateStore.cs 9KB
ProgressJsonHandler.cs 9KB
DBWrite.aspx.cs 8KB
FileControl.cs 8KB
IMultiRequestUploadModule.cs 8KB
Demo.aspx.cs 7KB
UploadedFile.cs 7KB
ProgressBar.cs 6KB
IUploadProgressState.cs 6KB
DetailsControl.cs 6KB
SimpleWebRemoting.cs 6KB
AdaptiveUploadStateStoreProvider.cs 6KB
SessionBasedUploadStateStoreProvider.cs 5KB
UploadedFileCollection.cs 5KB
GreyBoxProgressBar.cs 5KB
DBRead.aspx.cs 5KB
UploadStorage.cs 5KB
NonfilePortionTooLargeException.cs 5KB
HiddenPostBackID.cs 4KB
HashedDemo.aspx.cs 4KB
InProcUploadStateStoreProvider.cs 4KB
UploadProgressState.cs 4KB
FilesystemUploadedFile.cs 4KB
FilesystemUploadStorageProvider.cs 4KB
UploadTooLargeException.cs 4KB
共 1136 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
- lixingang112015-04-14很好,很适用的例子
玛格尔
- 粉丝: 18
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功