download a file only one time in vb.net and IIS - vb.net

I have a link
http://www.example.com/foldername/1.jpg
Is there a way to make this link usable ony once? In other words, if a user downloads this image and anyone tries to download it again (even the same user) the link will not work anymore.

You could use a VB.NET script that reads the image from a protected directory and outputs it to the response stream and then simply delete this image from the directory.
See here how to write an image to the response stream.

Related

Is there a way to set a file name when jspdf output()

My site draws a column chart. I have a button to save it as a PDF file showing it before saving.
The way it works now is this.
google.visualization draws the chart.
html2canvas takes a screenshot of the chart.
jsPDF inserts the screenshot in a PDF file and shows it to the user.
The problem is the name of the PDF file. It is something like 5d78c1eb-0829-4e7e-8ffc-71cf1f102f56.pdf and the url is blob:http://example.com/5d78c1eb-0829-4e7e-8ffc-71cf1f102f56
When user sees the PDF and clicks save he receives this awful file name.
Now I show the PDF this way:
window.open(doc.output('bloburl'), '_blank');
I can set desired file name if I change this line to this:
doc.save('sample-file.pdf');
But in such a case the file just downloads but I need to show it first.
Is there a way to show the PDF and give it a desirable name? I tried this:
window.open(doc.output('bloburl', {filename: 'myFileName.pdf'}), '_blank');
But it did not help.
Another way I see is not showing the PDF from jsPDF, but sending images to the server and making a PDF file there using TCPDF. The files made with TCPDF can have a name I give it, but I think it is dumb to send the images there and back.
So the question is how can I make a PDF and show it to the user with the name I want?
At the moment the answer is no. You can download it directly, as mentioned in the accepted answer of this question: Download with filename
But you create an objectUrl and therefore the filename is always the url.
Maybe you could create an browser-extension for this...but I haven't had the time to try yet. Furthermore, you can't expect your visitors to have the extension installed.

How can I upload a whole folder of PDF files, So that I can skim through each file without having to upload each one of them individually

I have a folder of PDF files, what I want to do is build a small app with directional arrows that when pressed should upload the next PDF file from the uploaded/Selected folder.
I have tried uploading single PDF and I was able to view it, but I'm unable to find any good resource on how to upload a whole directory inside the application for me to not upload each PDF every single time.
I should be able to change my current opened PDF to the next one inside the folder.
The way to do this in Vue is as follows:
Make a input field and attach the event "v-on:input" with the function that will be called when the input is selected.
Don't forget to add "webkitdirectory mozdirectory" for firefox and chrome browsers.
Inside the function fetch the input query via "document.querySelectorAll('input');". The information of files will be inside files object.

Download Excel file from URL

Background
I am attempting to automate the downloading of an Excel file given a URL. I know how to do this, and realize there are many examples for how to do this using either the webbrowser or webclient control however my situation is somewhat different.
Problem
If I simply paste the URL into a normal browser, it will result in asking me to save / open the file like normal. When using the same URL with either the web browser or web client controls, it results in no file. I believe this is because the URL is simply a SharePoint link, that sends a request to get the file, but is not the actual file itself.
This can be done for security reasons or whatever the case is but I was wondering if anyone has ever found a way around this?
Perhaps a way to even just emulate the browser, then emulate clicking save?
The URL for the Excel file does NOT end in .xlsx, it ends in something like:
webclient/zhZZXYRyAaLUgD?TC_file=redirs/viewdataset
which is why I think the server simply processes the request and then provides the browser the file.
I am attempting to do this in VB.NET but VBA or VB answers seem like they should work as well.
Fiddler Results
I seemed to find an easy way to solve my problem. After downloading my file within Internet Explorer, and then viewing my recent downloads, IE has an option if you right click and select "Copy Download Link". This puts the true download URL in the clipboard and actually works using the My.computer.downloadfile method.

CGPDFDocument: open PDF streamed or while file is not complete yet?

Situation:
(Large) PDFs are stored on an iOS device
The PDFs are encrypted using a Rijndahl algorithm
When tapping one of the PDFs, it gets decrypted and afterwards viewed using a PDF viewer I implemented. The viewer is using the Core Graphics functionality to render the document page by page.
Issue:
With the documents being large enough, encrytion will take a while.
Viewing can only be started after the whole document has been decrypted into a temp file.
I'm wondering, if there is a way to...
Pass some kind of stream to CGPDFDocument instead of a file URL
Or any other alternative to be able to view as many pages as possible whil decrpytion is continued in the background?
If you cannot split your original PDF files down to single pages (as I suspect), then the following approach should work:
A: When still decrypting:
try to open the PDF document as you already do;
try accessing the document page you are interested in;
if it does not fail, render the page;
if it fails, then you know that page is not available yet (while decrypting);
while decrypting, release the pdf document each time you try to get a new page.
B: when decryption is done: do as you are already doing.
Please note that this is just a suggestion, I have not tried this while decrypting a document, but if point 1. does not fail, then this should work.

ASP Response.AddHeader Content-Disposition not working for Acrobat

I have a script that generates a temporary PDF file, binary-streams it to the client, then deletes it.
If you click on "Save Page As" in the browser File menu, it wants to save the correct file name that I specified through Content-Disposition.
However, if you click on the Save button in the Acrobat reader or Acrobat Pro, it wants to save the name of the script file, replacing ".asp" with ".pdf". It's like Acrobat completely ignores "Content-Disposition"
It's important that I don't use a static URL, but instead use a Dynamic script to generate the PDF, so that I can delete it immediately upon closing the stream. Otherwise, I can't know when the client is finished downloading.
Is there a solution to this? I've seen several threads, but none with an answer.
You can use a URL rewriter to point a "static" path to your dynamic script.
See this blog post on classic asp redirection.
So, you can have a link like:
http://www.example.com/12_234_file.pdf
Redirect to:
http://www.example.com/dynamic.asp?id=12&id2=234
The client will see the URL before it was re-written and should use that.