webapi mvc4 fileupload with progressbar using ProgressMessageHandler Class - asp.net-mvc

http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2 shows how to upload files. However I would like to have someone show me the code example where I can display the progress of the file upload using ProgressMessageHandler class. So far I was able to find examples of the class being used in WPF or console application, but I would like to use it either on the MVC controller method or the WebAPI method directly and show the upload progress to JQuery UI progress bar. Can someone post the sample code of how it can be done?

So you want to display the send progress on the client, by tracking the receive progress on the server? Keep in mind that the ProgressMessageHandler class is server-side code.
In order to do what you're proposing, every time the server receives a packet, it would need to send back to the client the details of the progress. But in order for a web browser to receive any data, it must first request it. So the browser would have to upload the file, and simultaneously be asking the server for progress updates?
I think you've got this all backwards. If you're wanting to display file upload progress in a web browser you need to look at browser technologies. Like the HTML5 upload (there's plenty of examples out there of using HTML5 to track file upload progress). Or one of the pre-HTML5 options that got a lot of mileage was Shockwave Flash plugins. GMail does, or at least did use a Shockwave Flash plugin for progress reporting on attachment uploads for example.

Related

Send email as PDF in ruby on rails in Typo3

I have an web-application in RoR which calculates some energy values and investment money. I use ajax to send the data from the web-browser to the server. It is something like this: Browser-server-Browser-Server-Browser
This web-application is already integrated in typo3 and I want to implement a PDF button to send the results per email (in other words, a photo of the page with the results).
I have heard an option would be to generate some links in RoR to be used in typo3 (when clicking on it, it would open exactly the web-application with the results already calculated). But as a newbie, I do not really know which would be the best approach.
Any recommendation?
A screenshot of the page can be done client-side:
http://html2canvas.hertzen.com/
You could even have another page with the same results that you use only for the rendering of the result page what you use for making a clean screen-shot (you might not want to have the footer, menu and other elements on that page, only the results)
Once you have your screenshot, you can upload it to your server where you can use it to create a PDF of that image and then send it with any mail API you prefer to use.
info about TYPO3's mail api can be found here:
https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Mail/Index.html

Delphi - read content that is loaded dynamically

I want to read the content (html) of a certain URL. I send a GET command, receive the html and I do what I want to do with it, no problem here.
The problem happens when a site loads more info into itself when you scroll down (like Facebook does), so the content I receive is the default one without the parts that are yet to be loaded. Any idea what can be done to retrieve the next parts automatically so I can read more and more of the content of such site?
I saw something about phantomJS but I'm developing a desktop application (using Delphi) so I can't use it. Thanks.

JSF print screen like capture

I am generating some linecharts via JSF (Primefaces).
So charts are accessible and generated nicely via accessing in any browser.
However i need to send those charts via email to certain persons cause they do not want to click on a link so this should be automated.
Is there a way to generate an image out of what the JSF is rendering ?
Thanks
Charts are canvas based and can be exported as static images with client side api.
Take a look here:
http://www.primefaces.org/showcase/ui/chartExport.jsf
Primefaces use Javascript Libraries to render the charts. You would have to process the browser output before sending the email.
(Also, lazy managers)
You would have to dig into the Java Image API (not JSF) in order to plot the graph (from the raw data) into an image if you want the JVM to send the email.
If you want to just automate the process in your machine to send the emails (so you can send the emails in one click instead of doing it all manually, be mindful of this caveat:
You would have to generate a custom page with print CSS and your email layout, then use a browser plugin that sends the email on a click.

can i use input type = file in my single page application

I'm writing my first single page application and have a requirement by where the user is going to need to upload documents and/or images.
Is this a show stopper for using a spa or is there a work around?
I seem to be able to find very little on this on the net so I'm wondering if this requirement would mean creating a normal mvc site?
Its possible to upload files using ajax, so no show stopper there. you might need a controller to accept the file though, but that shouldn't be an issue.
Check out this tutorial on an ajax upload
http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/
or you can check out uploadify, i think that does file upload via ajax too

MVC Upload ProgressBar

I have read many links in this forum and the asp.net forum and searched Google. I have found loads of progress upload bars, but not one that suits my specific needs. So i was hoping someone could help. I need an upload progress bar that does not use, flash, php, html 5 or any codebehindfiles, was hoping to find a javascript pure upload progress bar. Has anyone used anything like this before?
Thanks
Marcel.
Valums Uploader. It uses pure Javascript (uploads file using Iframe)
I'm not sure if that's possible with all the stipulations you've added. The upload is a purely server side process. You can use javascript to poll the progress using ajax, but that still requires a server side code file.
The file uploader I always use is http://slfileupload.codeplex.com/
This allows you to do multiple files, have progress bars, and hook into events with javascript. It is silverlight, so that might rule it out for you.
The only other thing I can think of, with the limits you've imposed, is showing a 'working' gif, like a spinner or something. It's not true progress, but it'll show the user that something is happening.
Here's one that doesn't use anything except Javascript/HTML/CSS
http://aquantum-demo.appspot.com/file-upload

Resources