MVC4 - File download on iPad (instead of showing in browser) - asp.net-mvc-4

Is it possible to download a file using MVC4 to iPad instead of showing the file in the browser when clicked?
On my webpage, I am showing a table of files (can be any type) and when clicked on the file names, the file should be downloaded to the iPad.
I am using:
Public Sub GetItem(ByVal fileId As Guid)
Dim sDirectory As String = Commands.Folder.MapFullPath(fileId)
sDirectory = ApplyClusterServerHACK(sDirectory)
Me.HttpContext.Response.Clear()
Me.HttpContext.Response.ContentType = "application/octet-stream"
Me.HttpContext.Response.AddHeader("Content-Disposition", "attachment;filename=" & System.IO.Path.GetFileName(sDirectory))
Me.HttpContext.Response.TransmitFile(sDirectory)
Me.HttpContext.Response.End()
End Sub
to get the file and it's working perfectly in desktop browsers. It is prompting if I want to open it or save it, and choosing save opens up the location dialog box where I can select where to save it.
Can this be done in an iPad? If not, do you have any alternate idea how to make it work? Using the Back button on the browser is off-limits since I am running the application full-screen using a "stub" without any menu bars.

Related

Can I pick a dropbox file through FileDialogue and store the path in my database?

I have a database hosted on SharePoint.
I have a continues form called frmAttachments. It has one PK field, one text field (txtAttachmentPath) and one combo (cboFileType). Text field txtAttachmentPath has a property "Is Hyperlink" set to "Yes".
I made a command button that open FileDialogue, picks the file and pass the path to the txtAttachmentPath field as its value. When I click the txtAttachmentPath field, it opens the file. All beautiful so far...
However, I can only pick files on my local machine (the same would apply to any other user). Is possible that I can pick and store the path of a dropbox file using the same technique: click on command button, get navigated to the organisation's DropBox folder, select a file and get that path stored in my txtAttachmentPath field, so that it can be seen and opened by any database user?
The code below (for my command button cbtAttachment) works like a charm, but I can only pick and store files from my local machine, meaning that other dbs users cannot access it.
Private Sub cbtAttachment_Click()
Dim f As Object
Dim strFullFilePath As String ' Full file path
Set f = Application.FileDialog(3)
f.allowMultiSelect = False
f.Show
strFullFilePath = f.SelectedItems(1)
Me.txtAttachemtPath = strFullFilePath
End Sub
I had a similar issue with hyperlinking to specific directories in Dropbox.
Install Dropbox desktop, if the application is not installed already. Dropbox Application Install Link
You will want to save the attachment paths so you do not run into issues with differing user profiles
SetPathToDropbox = Environ$("%UserProfile%") & "\Dropbox - \path\to\document\or\file"
A similar post for OneDrive was what help me through this Right Here.
I still haven't found a solution for navigating to a file on our organisation's DropBox (FileDialogue cannot see it for some reason), but I did make it work through OneDrive where colleagues can save paths to shared reports, photos, etc. within the DBS, and then open those files on their individual laptops, desktops, etc.

VBA IE 10 Automation - Automatically Save PDFs

I'm trying to automate the process of saving PDF invoices for bookkeeping purposes. The method suggested here does not work because a login is required to access the invoices.
I currently have a macro that navigates to the page, logs in and opens the links to each invoice. The URL scheme for these invoices is .../account/invoice/?invoice_number=XXXXXX. Navigating to each of these URL brings up the files in the
window. I would like the files to automatically save, but according to this page, the Always ask before opening this type of file option was depreciated from IE 10 and 11 due to security reasons.
I attempted to automatically click Save using this method, but the code here seems to be for a different version of IE.
The line:
hWnd = FindWindow("#32770", "File Download")
was modified to:
hwnd = FindWindow("#32770", "View Downloads - Windows Internet Explorer")
This successfully captures the download window, but it fails to find the &Save button for me to click. My guess would be that it's because there are multiple save buttons.
Any ideas would be greatly appreciated! Thanks.

open mxd in arcobjects vb.net add in

I am trying to open an mxd in an ESRI ArcMap add-in using vb.net. The user starts with a blank mxd and runs a tool to open an mxd that is stored in a file. The mxd that is opened by the code has some feature layers and some graphics in the layout.
So far I have:
Dim mapdoc As IMapDocument = New MapDocumentClass()
mapdoc.Open("D:\__Test\LockItInPMAV.mxd")
The document opens because I can get its filename via:
MsgBox("Filename: " & mapdoc.DocumentFilename)
However the data view and layout view remain blank, they do not show the contents of the opened file.
How can I get the opened file to display in the current ArcMap session?
Thanks,
Luke.
I'm working in C#. I'm not sure if you can load an mxd after it is loaded.
You would either need to load a new arcmap instance and pass the mxd name as a parameter:
var expanPath = Environment.GetEnvironmentVariable(Properties.Settings.Default.arcmapLaunchPath,
EnvironmentVariableTarget.Machine);
string Cmd = string.Format(#"{0}\arcmap.exe", expanPath);
ProcessStartInfo startInfo = new ProcessStartInfo(Cmd);
startInfo.Arguments = Properties.Settings.Default.MxDPath;
Process.Start(startInfo);
Process.GetCurrentProcess().Kill();
The MXD holds so much details on how the instance of arcmap operates that it is not easy to reload it. Our esri contractor confirmed this.
I am told that Pro, has changed this completely.

Copy image from webbrowser to clipboard

I need to copy an image from a webbrowser control to my clipboard, because the image changes on every reload, and I tried to get the "src"-attribute and changing my picturebox.imagelocation to that, but the image on the picturebox differed from the picture on the webbrowser control.
I'm trying to automate a web service, and it requires a captcha to be filled out, and it changes every time the page is loaded, that's why I need to get the one that is currently displayed.
Assuming you are using Windows Forms (need to change the way to get document if you use WPF) and the user did not block clipboard access in IE zone settings
Dim doc As IHTMLDocument2 = DirectCast(webBrowser1.Document.DomDocument, IHTMLDocument2)
Dim body As IHTMLElement2 = DirectCast(doc.body, IHTMLElement2)
Dim imgRange As IHTMLControlRange = DirectCast(body.createControlRange(), IHTMLControlRange)
Dim image As IHTMLControlElement = DirectCast(DirectCast(doc, IHTMLDocument3).getElementById(sImgID), IHTMLControlElement)
imgRange.add(image)
imgRange.execCommand("Copy", False, Nothing)
Pseudo code:
For each element by tag 'img'. Get the 'src' attribute. Fire up an instance of HttpWebRequest or use WebClient.DownloadFile for the source.
You will need to do some trickery determining where the source is in relation to the url. For instance the src could be '/img/pony.jpg', in which case you'll need to get the url's root from the WebBrowser control to make it 'http://mylittle.com/img/pony.jpg'.

gwt-ext file upload

I am trying to do a file upload from gwt-ext without bringing up the dialog box. To do this, I created a FormPanel and added the appropriate fields to it. Then did a form.submit(). This doesn't seem to work. Any idea why? The code is shown below.
final FormPanel uploadForm = new FormPanel();
uploadForm.setVisible(false);
uploadForm.setFileUpload(true);
final TextField sourceFile = new TextField("File", "sourceFile");
sourceFile.setVisible(false);
sourceFile.setInputType("file");
sourceFile.setValue("/tmp/test.txt");
final TextField targetFile = new TextField("Upload As", "targetFile");
targetFile.setVisible(false);
targetFile.setValue("different.txt");
uploadForm.add(sourceFile);
uploadForm.add(targetFile);
final String url = GWT.getModuleBaseURL() + "/uploadFile";
uploadForm.getForm().submit(url, null, Connection.POST, null, false);
I tested the servlet on the server side with a simple html form and it works correctly. Only the GWT-EXT version doesn't seem to work.
I found out why the above piece of code is not working. The primary issue here is that file uploads are blocked by the browser due to security reasons if the upload form has not been rendered and/or if the form has been modified after the user clicks the submit button. If the browser did allow such things, then any file on the system can be easily uploaded without the user's knowledge.
Solution to to the above problem is to bring up the dialog box, do the upload in the event handler for the submit button and in the onActionComplete method of the form listener, do any other processing.
The whole idea of uploading without dialog box looks like a security breach to me. I can imagine an application that steals passwords file whenever opened, if only the above would be possible.