Trying to upload a data byte[] to ASP.NET via "WebClient" and OpenWriteCompleted in Silverlight5. If the data size is smaller all the data gets written correctly. If I upload say a 500kb file I get data corruption.
How do I upload a 500kb file to ASP.NET ??
NOTE: I'm trying to upload a zip file into a MSSQL varbinary(MAX) column in my database.
Never mind, it was a zip compression bug on my part.
Related
Please help to get file created date from asp.net ascx (ex.)
This is load image from page
Bitmap originalBitmap = new Bitmap(flpContainer.FileContent);
// how to get image **created date** via uploading from local machine (not uploading date)
I want try with FileInfo class, but for asp.net it not work to read a local file properities.
I have functional in web : User upload images from local file system to our application and I want take image created data in File system. I can create new column for created_date in DB, but how I can take created Date image from FS (not created uploading date just created date in local machine via asp.net).
#Eldar, that information is actually lost as it is not transmitted as part of the file upload. You can only get information about the file name. You could request your users to supply a create date as part of the upload or you could set it yourself as part of the upload process to DateTime.Now.
Sorry I couldn't be of more help
When opening a file in new browser window that is stored in the file system with the url stored in the database, the solution is simple with the javascript method:
[var windowObjectReference = window.open(strUrl, strWindowName\[, strWindowFeatures\]);][1]
However, when storing files as blob in the database (SQL Server) there is no url pointing to the file. What is the best practice for retrieving the file for the user? Do I need to copy the file to a temp folder and then provide the url dynamically? Then delete the file after a certain point?
I know that storing the file in the file system would be easier to code, but I have chosen to store it as a blob for all the benefits that come with a DBMS.
Thanks for your help
Your web server will have to write the BLOB's bytes to a response stream, plus an appropriate Content-Type and Content-Length header so that the browser knows how to treat those bytes. Use a tool like Fiddler and browse to google.com. You can see what Google's responses contains for images on the page. Your goal is to generate a response in a similar fashion.
I'm working on a server/client application, in which the client has the ability to upload/download a file, which will be stored in SQL server (2012) as varbinay(max). The problem is that I want that the file will be uploaded directly to the database without saving the file on the server's hard drive, using ReadAllBytes method, which only accepts a path parameter.
Here is a fragment of the code used in the server side:
HttpPostedFile file1 = context.Request.Files[0];
byte[] buffer = new byte[file1.ContentLength];
file1.InputStream.Read(buffer, 0, file1.ContentLength);
Here is the code user in order to write into a file from data in the database:
foreach (var file in list)
{
System.IO.File.WriteAllBytes(path + file.FileName, file.FileContents);
}
The HttpPostedFile comes with an input stream you can read from. Read it into a byte array, then store it in the database. Or if your database interface (in the case of EF this is unlikely) directly accepts a stream, just put it in as-is,
Do note that ASP.NET (or was it IIS?) may store a file upload temporarily on disk anyways, if it's very large.
I have the following queries on fetching a BLOB data from Oracle (
I am trying to use OracleDataReader - .Net to read the BLOB value.):
Is it possible to read a BLOB data on Oracle database as chunks without loading the entire BLOB on to server memory? I believe OracleDataReader.GetBytes() will load the entire blob on server memory.
Passing a null buffer on to GetBytes() fetches the size of the BLOB but would that require the BLOB to be loaded on server's memory?
What would be the optimal way to fetch the BLOB size and BLOB data as chunks without loading the entire BLOB in memory?
Look at DBMS_LOB.READ
Am using asp.net's FileUpload control to upload a word file to the server.
I want to encrypt the contents of this file (using our custom encryption API) and then save it in the server.
How do i achieve this?what should be my approach?
Thanks.
Whatever you do on the server side, do realize that while the data is transfering over the wire, it will not be encrypted with your custom api. You will need to upload the file using an ssl connection in order ensure the data transfer is secure.
if you have your own custom encryption API, you should use it to encrypt in a temporary file and then upload the temporary encrypted result, and delete it after upload complete.
The FileUpload control gives you a handle to the file. Read the data from the file stream, encrypt it and write it to a FileStream. If the encryption process is CPU intensive and/or takes a lot of time, save the file in a temp directory and start a new thread that reads the file, encrypts its contents, saves it to a new file and deletes the temp file.
maybe u should write your own encryptor as an app and then decrypt that file on the server
this article could help u : file encrypt / decrypt