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
没有合适的资源?快使用搜索试试~ 我知道了~
附件上次控件(开源)
共997个文件
html:687个
cs:89个
gif:34个
4星 · 超过85%的资源 需积分: 0 21 下载量 169 浏览量
2008-12-24
14:31:57
上传
评论
收藏 1.97MB ZIP 举报
温馨提示
开源的大文件上传组件NeatUpload
资源详情
资源评论
资源推荐
收起资源包目录
附件上次控件(开源) (997个子文件)
SWFUpload.as 23KB
FileItem.as 1KB
Delegate.as 156B
TestControl.ascx 431B
MultiRequestUploadHandler.ashx 89B
MultiRequestUploadHandler.ashx 89B
UploadStateStoreHandler.ashx 87B
UploadStateStoreHandler.ashx 87B
Demo.aspx 7KB
SmoothProgress.aspx 7KB
SmoothProgress.aspx 7KB
DBWrite.aspx 6KB
Progress.aspx 5KB
Progress.aspx 5KB
HashedDemo.aspx 5KB
Processing.aspx 3KB
TriggerInGridViewAfterProgressBar.aspx 3KB
Bugs.aspx 3KB
Demo.aspx 2KB
MultipleBars.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 337B
Build 286B
Web.config 2KB
Web.config 2KB
log4net.config 1KB
Web.config 639B
Web.config 491B
Web.config 325B
Web.config 282B
Web.config 282B
UploadHttpModule.cs 32KB
SqlServerBlobStream.cs 31KB
FilteringWorkerRequest.cs 27KB
UploadModule.cs 18KB
DecoratedWorkerRequest.cs 17KB
Config.cs 15KB
ProgressBarBase.cs 13KB
ObjectProtector.cs 13KB
SqlServerUploadStorageProvider.cs 13KB
SqlServerUploadedFile.cs 12KB
InputFile.cs 12KB
ProgressPage.cs 12KB
MultiFile.cs 11KB
IUploadModule.cs 11KB
UploadState.cs 10KB
MultiRequestUploadModule.cs 10KB
DBWrite.aspx.cs 8KB
UploadStateStore.cs 8KB
IMultiRequestUploadModule.cs 8KB
Demo.aspx.cs 7KB
UploadedFile.cs 7KB
FileControl.cs 6KB
ProgressBar.cs 6KB
IUploadProgressState.cs 6KB
DetailsControl.cs 6KB
SimpleWebRemoting.cs 5KB
UploadStateStoreProvider.cs 5KB
UploadedFileCollection.cs 5KB
DBRead.aspx.cs 5KB
NonfilePortionTooLargeException.cs 5KB
GreyBoxProgressBar.cs 5KB
HiddenPostBackID.cs 4KB
HashedDemo.aspx.cs 4KB
SessionBasedUploadStateStoreProvider.cs 4KB
FilesystemUploadedFile.cs 4KB
UploadProgressState.cs 4KB
FilesystemUploadStorageProvider.cs 4KB
UploadTooLargeException.cs 4KB
InProcUploadStateStoreProvider.cs 4KB
AdaptiveUploadStateStoreProvider.cs 4KB
UnloadConfirmer.cs 4KB
Progress-1.0.aspx.cs 4KB
UploadStorage.cs 3KB
MyLog4net.cs 3KB
FieldNameTranslator.cs 3KB
MultiRequestUploadHandler.cs 3KB
MultipleBars.aspx.cs 3KB
HashingFilesystemUploadedFile.cs 3KB
SqlServerInputFile.cs 3KB
ArmoredNameValueCollection.cs 3KB
UploadStateStoreHandler.cs 3KB
MoveToOptions.cs 3KB
UploadStatus.cs 3KB
InvalidStorageConfigException.cs 2KB
UploadException.cs 2KB
ProgressInfo.cs 2KB
共 997 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
fenglixin
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1