简体   繁体   中英

BULK INSERT permission denied - BLOB vs FILESTREAM

My company is very strict when it comes to security. My project, (built using VB.Net and SQL Server 2008) requires that users upload PDF files which then need to be stored into the database along with the associated path. Because the files will be just about 256kb or less, I wanted to insert the files as Single BLOB . My table has two columns Path as varchar(50) and File as varbinary(max) . My SQL query looks something like this:

INSERT INTO [DBNAME].[dbo].[SOMETABLE](PATH, FILE)
values ('C:\Somefile.pdf', (SELECT * FROM 
OPENROWSET(BULK N'C:\Somefile.pdf', SINGLE_BLOB)
AS import ))

Unfortunately, I only have read and write permissions on the database, thus yielding the following error: You do not have permission to use the bulk load statement. I have read this post but for other security reasons, I will not be granted Insert or ADMINISTER BULK OPERATIONS permissions. From other posts that I have read, without the permissions this option seems to be a dead end.

Now, I am looking into using FILESTREAM to insert the files but will not be able to create a new database. Can I accomplish this by enabling FILESTREAM on an existing database and database table and work with those? I have been on this for two days, any help or ideas would be much appreciated.

If you can't create a new database, I'm guessing they won't let you alter an existing database either. You can add FILESTREAM capabilities, but it requires that you at least create a new FILEGROUP. It also requires that the server configuration be changed if it isn't already set up to support FILESTREAM capabilities. Again, this sounds unlikely in the environment you describe. Also, FILESTREAM is generally recommended for larger files (>1 MB) then the 256KB you mention.

Since they are so strict in your environment you might try loading the document into your VB front end, encoding it and storing it to the database from there as a byte data insert from there. It won't require the BLOB/BULK insert and sounds like it might be a better alternative in such a restricted environment.

Why do you not just load the file up via normal SQL statements and binary array? The size is small enough for this and it means that you only need access to the files from your app, not the server needs to find and read them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM