How to save multiple files to database rather than disk - asp.net-mvc

I tried to apply the method on this page, but this sample save the files to disk instead of Database. So, could you please inform me what changes should be made on the sample method or is there any sample using this Kendo Upload to save multiple files to database?

The following method declaration -
private IEnumerable<string> GetFileInfo(IEnumerable<HttpPostedFileBase> files)
which receives the uploaded files have IEnumerable<HttpPostedFileBase> as parameter. It is collection of all the uploaded files. Each file exposes a property InputStream. For more information visit this msdn page
So now that you have the file content in form of stream, convert this stream into byte[] and save this to database.
Some suggestion are posted here.

Related

Uploading files in VSTS extension

Referring to the link here:
https://learn.microsoft.com/en-us/vsts/extend/develop/data-storage.
Does the "documents" for the data storage refers to any file types?
Can we upload files via VSTS extension?
Ie. Is it possible to invoke a server side implementation using aspx or php to store a file inside my extension?
As Jazimov said that you can’t store the files in VSTS extension data storage.
I recommend that you can upload the files to a repository of VSTS through REST API (e.g. Add a binary file) in your VSTS extension, then store the necessary information (e.g. server path, file name, objectId etc) in data storage.
The Documents object is a collection of Document objects. Document objects are deserialized as JSON objects.
When you ask if "documents" can refer to any file type, the answer is "No". Documents are not files. They start as C# objects that are serialized then persisted to a data store. When retrieved, they are returned as JSON strings.
You can encode a file into your data structure before storing and then the returned JSON will contain your deserialized file information. See Binary Data in JSON String. Something better than Base64 for more details.
The last part of your question: Of course your can invoke a service that uploads and downloads files. You would have to write that code logic on your own--it's not part of an VSTS extension's data-storage subsystem.

Upload images/files to DB with asp.net MVC

I would need some help I have my own Project going on and i would need some help with how to upload images/files to database using entity framework code first
I want to be able to have form with content like title/bodytext etc and file uploading. I'm pretty new to c# or even web developing. I have a model class with Byte[] but when I upload it to db it says null.
And then when I loop through database, I want to display the title, body text and the image I uploaded for each post I did.

Rails, Audit Log in View

I have a Model called file.rb that handles a files data table. This was done so that I can upload excel files from a file index.html.erb, and have the file name stored, see who uploaded the file, when it was created, etc(just tracking the files). These Excel files have many rows and each row have a bottle object with many attributes. During the create method, after save, I send the uploaded file to another model `bottle.rb'.
The bottle.rb model handles opening the Excel file and importing the information from the Excel file into the bottles data table.
I would like to be able to create an audit log with a message telling me success or failure of an uploaded excel file. Once the file passes the validations, I would like to see how many updates and new inserts to the bottles table. And be able to see this in the view where I upload the Excel file. I appreciate any helpful tips! I made an activity feed but for the entire application, but I am unsure how to go about to do this task.

MVC: when is a file uploaded?

When uploading files to a server and calling a controller method does a HttpPostedFileBase contain the entire file or just information such as name, path, etc?
What I want to know is if the file is uploaded to the server right away or not until calling SaveAs(path) ?
As the file is part of your request, it is uploaded immediatly. It is just buffered into a tempfile which the system will delete once you send the Response.
If you use SaveAs, you just transfert the file into a permanent location.

How to send a file to the browser using ASP.NET MVC controller action?

I have an application where I allow my users to upload a file of any type. I save this in the file system on the server. The application will only be accessed by two users, so I don't need to worry about uploading any dodgy files.
How do I allow my user to press a button on an MVC form to request the file be sent back via the browser and be presented with the standard save/open dialog?
I want to return any type of file, and the example I've found always specify the type of file being returned. Is there a simple example of this?
See FileResult and derived classes.
An alternative approach is to set HttpContext.Response.ContentType to the proper mimetype and then writing the contents of the file with HttpContext.Response.OutputStream.Write ().
Useful if, for example, the data is not in a local file but stored in a database as a binary blob.

Resources