简体   繁体   English

批量插入权限被拒绝-BLOB与FILESTREAM

[英]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. 我的项目(使用VB.Net和SQL Server 2008构建)要求用户上载PDF文件,然后将其与关联的路径一起存储到数据库中。 Because the files will be just about 256kb or less, I wanted to insert the files as Single BLOB . 因为文件大小约为256kb或更小,所以我想将文件插入为Single BLOB My table has two columns Path as varchar(50) and File as varbinary(max) . 我的表有两列Path为varchar(50)Filevarbinary(max) My SQL query looks something like this: 我的SQL查询看起来像这样:

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. 不幸的是,我仅对数据库具有读取和写入权限,因此产生以下错误: 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. 我已经阅读了这篇文章,但是出于其他安全原因,我不会被授予InsertADMINISTER BULK OPERATIONS权限。 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. 现在,我正在研究使用FILESTREAM插入文件,但将无法创建新数据库。 Can I accomplish this by enabling FILESTREAM on an existing database and database table and work with those? 我可以通过在现有数据库和数据库表上启用FILESTREAM并使用它们来完成此操作吗? 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. 您可以添加FILESTREAM功能,但至少需要创建一个新的FILEGROUP。 It also requires that the server configuration be changed if it isn't already set up to support FILESTREAM capabilities. 如果尚未将服务器配置设置为支持FILESTREAM功能,则还需要更改服务器配置。 Again, this sounds unlikely in the environment you describe. 同样,在您描述的环境中听起来不太可能。 Also, FILESTREAM is generally recommended for larger files (>1 MB) then the 256KB you mention. 另外,通常建议将FILESTREAM用于较大的文件(> 1 MB),而不是您提到的256KB。

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. 由于它们在您的环境中非常严格,因此您可以尝试将文档加载到VB前端,对其进行编码,然后从此处将其存储为数据库,作为从此处插入的字节数据。 It won't require the BLOB/BULK insert and sounds like it might be a better alternative in such a restricted environment. 它不需要BLOB / BULK插入,听起来像在这样的受限环境中可能是更好的选择。

Why do you not just load the file up via normal SQL statements and binary array? 为什么不仅仅通过普通的SQL语句和二进制数组加载文件? 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. 大小足够小,这意味着您只需要从应用程序访问文件,而服务器无需查找和读取它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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