Dowlnload with axios and Browser - browser

I have a vuejs application that works with .net core api. there are some files on API in the API that I want to download. the problem is for security reasons I cannot just put files in wwwroot and create an open link.
So I created a controller which gets the token and some info and after authorization returns the file.
if the file is big I have to wait for Axios to download in javascript and then I can create a link for the browser to Download it.
Is there any way I can download the Result in Browser or third-party softs Like IDM???

Related

How to logging in to asp.net website using node.js

I want to login and get my transcript from my school's website using nodejs. I checked the network flow while logging in. Website uses asp.net and there is __VIEWSTATE __VIEWSTATEGENERATOR and __EVENTVALIDATION parameters passed to the form-data. I think this values are randomly generated on the browser. How can i do the same thing on node.js? However it works when I run it by copying request from chrome devtools and pasting it in postman. But why it doesn't work in node?

How to download multiple files using ExpressJS one API call

I'm quite new to expressjs and I'm developing a web application which acts as an API application. There is a react frontend application also. When a button is clicked in the client app it will send an API call to the backend app and will download a file. That scenario is working fine.with the following code.
const file = `${__dirname}/upload-folder/dramaticpenguin.MOV`;
res.download(file); // Set disposition and send it.
});
But now I have a requirement to download multiple files from a button click. How can I do that .
Can someone help me here.
An HTTP response can only have one file. Really, "downloading a file" in HTTP means serving a response with a Content-Disposition: attachment header, to hint to the client that this response should be saved to the filesystem instead of rendered in the browser.
To download multiple files, you want the client code to initiate multiple HTTP requests (probably to different URLs), and the server can respond to each request with a different file. Note that many browsers will refuse to download multiple files in response to a single user action (for fear of flooding the user with unwanted files) or will at least prompt for confirmation before doing so.
If you cannot change your client-side code to make multiple requests, you will need to package your files inside a single file archive.

Sending client file download link

I have a nodejs backend and I want to send a file download link to the client such that, the file is directly accessible by the client. The file types are JPEG and PNG. Currently, I am serving these files as data-uri but, due to a change in requirements, I must send a download link in response to the file request and, client can download the file later using that link.
Now the current workflow exposes a path /getAvatar. This path should send a response back to the client with the file link. The file, is stored in /assets/avatars relative to the server root. I know I can express.static middleware to send back static resources. However, the methods I have seen so far, res.send() and res.download() both tries to send the file as attachment rather a link that can be used later to download.
Basically, the behavior is like a regular file sharing site where, once a file is clicked, a link to it is generated which, is used for downloading the file. How can I do this?

swagger-node only to serve API Docs

Is there a way to install and start only "reduced" Swagger-node configuration, being able only to serve API specs?
I am not using swagger-node web server, as I have my own.
I would just use swagger-node to visualize nicely the APIs.
UPDATE:
I installed the swagger-ui as explained here: http://idratherbewriting.com/pubapis_swagger/#b-set-up-the-swagger-ui
Unfortunatelly, I cannot change the URL to point to my own file. If I follow the instructions, copy ma YAML in "dist" folder and change the URL to "my.yml" and open index.html in the browser, it tries to fetch "...index.html/my.yml".
How to fix this?
You can start your swagger lerning from : http://swagger.io/swagger-editor/
You can create documentation, API authentication, models etc.
It will create a JSON and you can test your json for UI and functionality over here. http://petstore.swagger.io/
You can download this template and can upload on your domain. its an HTML template so can easily upload on any hosting.

How to use dropbox API from chrome extension content script?

If I write a chrome extension, it normally consist of multiple parts:
One is the devtools page which is a normal HTML page with origin set to
"chrome-extension://<guid>/filename". On that page I can use
the Dropbox API to get user confirmation via HTML popup and then use
the saved auth info and do all work via the Dropbox javascript library.
Another part of extension is the content script which is executed
in the context of specified third-party web pages ("injected") and have
origin cookies and web storage shared with them.
Is it possible to also use the Dropbox JavaScript library in that content script?
I can't call authenticate in interactive mode since it will re-ask for confirmation for each different webpage I'm injected into. And calling authenticate without interactive will fail since the content script doesn't share the origin, cookies and web storage with the devtools extension page :(. Maybe there's some way to "pass" the Dropbox auth info from the part of the extension that offers GUI and where user successfully confirms dropbox usage to the parts of the extension that are GUI-less, like content script or background page?
I have managed to get Facebook working from code injected into a web app via a content script. I suspect there are multiple ways, but what I did was take advantage of the chrome.identity API to do the OAuth work for me, specifically the launchWebAuthFlow().
This can only be done in the background page (in my case an event page), but I send messages to the event page which replies with the access_token, which can then be used in URLs in the same was as the 'web' technique - i.e. in HTTP requests with XHR.
You can send/receive messages via the content script (using events on document), but I decided to do it directly using "external" messages with the chrome.runtime.sendMessage() API in the web app context, and chrome.runtime.onMessageExternal() in the background script. This requires adding "matches" for the URLs you're injecting code into in an "externally_connectable" section of the manifest.json.
I believe this can be adapted to make it work with Dropbox.

Resources