OpenERP 7: How to view/ download an uploaded file? - upload

I have a field to upload a file to my form. Now I want to be able to view it without downloading the file (it's a photo and no editing of the file is required). When I do download the file I would like to have it keep its original name instead of being renamed to a generic name (ex. original_name.* stays original_name.* instead of becoming serial_number_22.*).
I have the following.
In my .py file:
'file_upload' : fields.binary('Sales Contract'),
In my .xml file:
<field name="file_upload"/>
With kind regards,

Please have a look at this module Document Management System. This helps you in uploading and associating files to individual records. And separately under knowledge menu you can organize, view, share files and folders and sharing via ftp is also an additional option.
I am sorry if your purpose is different. I thought this may help you.

If it's an image, you can use widget="image" to view it directly after upload.

Related

Open Zip file and view content (Videos, images, documents) in Rubyonrails

I'm planning to build a Rails app where user can view content of zip-file in their browser without downloading the actual content. Is this possible using RubyonRails? Please guide me a way forward.
Thanks,
Sure you can! Take at look at the rubyzip gem. With it, you could for example get the names of all files contained in the zip as follows
zip_filenames = Zip::File.open('foo.zip') do |zip_file|
zip_file.map { |entry| entry.name }
end
Then use this array to somehow display it in your application. If you'd actually want to open a video/text file contained in the archive, you'll have to extract it on the server to some temporary location, then open it through some other means.

How to create a reflowable content from the PDF?

I am going to developing an application, which is an epub. I have PDF files. I need to make those files as reflowable content(epub)... Then only the PDF files will be viewable in mobiles, tablets... etc.. Please suggest the solutions to make reflowable contents from the PDF...
If you don't mind using an open source software, go with Sigil.
If you want to learn innards of how to create by hand, or some tool of your own, Follow this. (This is a one month course, So you will not get all the content in one day, though).
Create the folder structure.
In a folder of your choice, create the following: META-INF (folder), OEBPS (folder), mimetype ( a file with exactly same name ).
Put application/epub+zip in the file mimetype. No spaces no lines.
Convert your PDF to text format. In Adobe acrobat, you will have file > export> .
Read the content from PDF, you will find some conclusions of how you can split them in to chapters or sub reading topics. Split according to the understanding of the book, and make so many text files.
Make sub folder structure. Make Images, Text, Styles (folders) content.opf, toc.ncx (files) inside OEBPS folder.
Put all your split files in Text folder created in step 5.
put all images extracted in pdf in Images folder
Put any styles (not describing here,) in Styles folder.
In the META-INF folder created in step 1, create a file called container.xml and fill with the following: <?xml version="1.0"?><container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/> </rootfiles></container>.
If you are able to do these many things sincerely, ping again, I would try to tell you what you should put in content.opf, and toc.ncx in created in step 5.
As an example, You can use some example from my site. Download from here and use them with caution. Do not distribute.
We're opening up a beta for our web based pdf reflow viewer at the beginning of 2015. Feel free to sign up to be part of our beta test. More info here:
http://flexpaper.devaldi.com/reflow-pdf-documents.jsp

(Rails) Uploading Directories

I need to upload multiple files on my website.
But I need not just a form for uploading multiple files, I need to upload whole directories.
How's this possible for the minimalist?
Yours, Joern.
According to my somewhat limited knowledge this is not possible, only file transfer is possible, not directories.
Here are some workarounds, based on discussion on Velocity Reviews and another discussion:
upload a zip, which you unzip at the server side
upload directories over ftp (web page can be a front end to this)
upload files one by one
I would go either for zip or ftp. Note: someone might have produced a gem that enables uploading directories (I know nothing of such thing, but I will be happy to find out, if there is).
Adding another option to the list provided by Sorrow:
upload via REST/JSON
OK, this is a partial solution, but it does give you the opportunity to write a script that reads your directory and POSTS to your website.

iOS file browser example

Does anyone have some sample code demonstrating how to make a "file browser" view? I'd like to be able to navigate through directories and drill-down the sub-directories and see files located within the various folders. I want the user to be able to create new directories/files and even select an existing file. Is there sample code out there already available to do this?
I don't know about sample code, but this wouldn't be too complicated to achieve using NSFileManager and a UITableView.
You can obtain arrays of directory contents using the subpathsOfDirectoryAtPath:error and associated methods of a file manager. These arrays in turn can populate a UITableView. It would be fairly easy to put together a navigation controller that could display a series of table views showing a file hiearchy.
Bear in mind, however, that you'll only be able to access the directories inside your application sandbox, unless you're running on a jailbroken device.
The iOS programming guide says that
You should never present users with the list of files in this directory and ask them to decide what to do with those files. Instead, sort through the files programmatically and add files without prompting.
This is assuming you are trying to implement file browse feature for your documents directory.
I'm an author of FileExplorer which is a file browser for iOS and fulfills most of your requirements.
Here are some of the features of my control:
Possibility to choose files or/and directories if there is a need for that
Possiblity to remove files or/and directories if there is a need for that
Built-in search functionality
View Audio, Video, Image and PDF files.
Possibility to add support for any file type.
You can find my control here.

where is the best place to save images from users upload

I have a website that shows galleries. Users can upload their own content from the web (by entering a URL) or by uploading a picture from their computer.
I am storing the URL in the database which works fine for the first use case but I need to figure out where to store the actual images if a user does a upload from their computer.
Is there any recommendation here or best practice on where I should store these?
Should I save them in the appdata or content folders? Should they not be stored with the website at all because it's user content?
You should NOT store the user uploads anywhere they can be directly accessed by a known URL within your site structure. This is a security risk as users could upload .htm file and .js files. Even a file with the correct extension can contain malicious code that can be executed in the context of your site by an authenticated user allowing server-side or client-side attacks.
See for example http://www.acunetix.com/websitesecurity/upload-forms-threat.htm and What security issues appear when users can upload their own files? which mention some of the issues you need to be aware of before you allow users to upload files and then present them for download within your site.
Don't put the files within your normal web site directory structure
Don't use the original file name the user gave you. You can add a content disposition header with the original file name so they can download it again as the same file name but the path and file name on the server shouldn't be something the user can influence.
Don't trust image files - resize them and offer only the resized version for subsequent download
Don't trust mime types or file extensions, open the file and manipulate it to make sure it's what it claims to be.
Limit the upload size and time.
Depending on the resources you have to implement something like this, it is extremely beneficial to store all this stuff in Amazon S3.
Once you get the upload you simply push it over to Amazon and pop the URL in your database as you're doing with the other images. As mentioned above it would probably be wise to open up the image and resize it before sending it over. This both checks it is actually an image and makes sure you don't accidentally present a full camera resolution image to an end user.
Doing this now will make it much, much easier if you ever have to migrate/failover your site and don't want to sync gigabytes of image assets.
One way is to store the image in a database table with a varbinary field.
Another way would be to store the image in the App_Data folder, and create a subfolder for each user (~/App_Data/[userid]/myImage.png).
For both approaches you'd need to create a separate action method that makes it possible to access the images.
While uploading images you need to verify the content of the file before uploading it. The file extension method is not trustable.
Use magic number method to verify the file content which will be an easy way.
See the stackoverflow post and see the list of magic numbers
One way of saving the file is converting it to binary format and save in our database and next method is using App_Data folder.
The storage option is based on your requirement. See this post also
Set upload limit by setting maxRequestLength property to Web.Config like this, where the size of file is specified in KB
<httpRuntime maxRequestLength="51200" executionTimeout="3600" />
You can save your trusted data just in parallel of htdocs/www folder so that any user can not access that folder. Also you can add .htaccess authentication on your trusted data (for .htaccess you should kept your .htpasswd file in parallel of htdocs/www folder) if you are using apache.

Resources