Currently I am working on a MVC web application that should have a creation dialog for some kind of entry.
It should be possible to enter some text information as well as upload documents, images, videos, etc.
The following problem arises:
Are there any general best practices for uploading the whole bunch of information at ONCE? The object should not be created in the database until the user really decides to submit the information.
I thought about some solutions
Storing the uploads with the FileAPI in the browser
Immediate AJAX-Upload when selecting files. But where to "cache" the file on the server? The entry is not in the Database since I am creating the object.
Creation of a database entry when opening the form? But this would result in junk in the database
Any suggestions are much appreciated
Thank you
Kind regards
I think this approach will be good to follow.
Have Session cache which will keep the files-bytes in server memory.
When user comes on the upload page, clear it.
When user uploads the files, save file-bytes on server session cache.
When user really wants to upload files - say - submit files - kind of button, get the files from session cache and upload in the database.
Clears the session cache when its saved in database.
In case of large files, like videos, you would like to create a temporary folder(per user), save files inside that folder - instead of session cache, and clear/delete the folder after the files are saved in database.
Related
In my company, we have a report generation team which maintains a local web application which is horribly slow. These reports get generated weekly. The data for these reports reside inside a database which gets queried through this report portal. I cannot suggest them to change the application in anyway (like memcache etc.) the only option I have is to somehow save these pages locally and relay.
As these are not static pages(they use database to fetch the data), I want to know is there anyway I can store these pages locally by running a cronjob and then have the super fast access for me and my team.
PS:This application doesn't have any authentication these are plain diffs of two files stored in the database.
There are lot of options, but the following one may be easy
Generate HTML page regularly and update the cache (cache entire generated html page with key obtained from the dynamic content uniqueness), with some kind of cronjob as you have mentioned. This job populates all the modified dynamic content # regular intervals.
Have a wrapper for every dynamic page content to lookup cache. If hit then simply return the already generated HTML page. Else, go through regular flow.
You can also choose to cache this newly generated page also.
Hope it helps!
I'm contemplating on how to store images in my new site.
Should I save the images directly to the database
OR
should I upload them to my server, while storing the path in my database?
Also, should it be the second choice, how does one retrieve the path of a file he uploaded previously?
You should definitely go with the second option as you can take advantage of the user's browser caching these images after the initial request. It also means your database wont be hit constantly for large files which is always a bad thing.
In CodeIgniter there are various parameters you can use to get the name / full file path to store in the database.
See http://ellislab.com/codeigniter%20/user-guide/libraries/file_uploading.html
Also take a look at this great SO question Storing Images in DB - Yea or Nay?
I tried CI's own libraries , its good but not best, Image moo solved all my problems, uploading, resize, crop etc..
http://www.matmoo.com/digital-dribble/codeigniter/image_moo/
I am using Joomla 2.5
I want to store user uploaded content (like images or general files) in the database instead of in the server.
Is there any existing setting which can be used to do this by default?
Note: I am interested in the user uploaded files. Joomla's own files can stay on the server or on in the database, either is fine by me.
The database doesn't store things like images, its stored information. Images and so on are always stored on the server. The only thing you could do is once an image is uploaded to the server, it stored information about it such as the format, dimensions etc in the database. Would be a good idea to use a gallery such as Phoca Gallery or JoomGallery. More can be found here.
If you are looking for a general file uploader then feel free to use my SWFUpload Component which is only for uploading in the admin backend however is a very simple component therefore will be easy to integrate into other components should you need to.
I wanna create a table somehow in wondows phone that holds data that never changes and the application querys that data. Pretty simple but not sure how to do it.
Example
a table with Name, Description
When you open the app all the theres an input box to enter a name then you press a button and the description displays.
Using isolated storage seems like you are writing all the data to a file everytime the a user opens the app. Is that how it works?
Using isolated storage seems like you are writing all the data to a file everytime the a user opens the app. Is that how it works?
No, IsolatedStorage is storage - you can think of it as "disk" - so everything in it is persisted between application runs.
When you first run your application, then you'll need to create your files there, but after that time, then the files will already be in place.
If you need to put a large amount of data into IsolatedStorage and then need to search that data later, then "lite" database solutions like http://sterling.codeplex.com/ or SqlLite might help
For test purposes simply hard code the values as a dictionary.
In the long term I suggest you store the information as a file in isolated storage.
Here is an article that describes how to load and save data to isolated storage
This question relates to ASP.NET MVC3 using the Razor Engine.
What I need to do:
Allow user to upload a comma delimted text file
On post, parse the file on the server (without saving to disk) and display a message to the user about the contents of the file in a different view.
Allow the user to choose "Yes" or "No" to perform a final import of the data within the file to some external database.
NOTE:
I have no problem uploading the file or reading the contents of the file or any of the obvious steps involved there. The issue I have is that I don't know the best way to accomplish the data persistence between views using MVC3.
Thanks in advance for the help.
Once you parse the CSV file into a model you could store this model into the Session so that if the user chooses "Yes" you would fetch the model from the session and persist it to the database. If you don't want to store large quantities of data into the session you could always save the model into some temporary file on disk and store only the path to this temporary file into the Session so that you could retrieve it later.
The best non-disk persistent storage in ASP.net applications is the runtime cache.
see documentation here