webclient.download downloading incomplete tiff image from a url - c#-3.0

I am using below code to download a tiff file from a lotus domino server.
string url
= "http://10.1.1.23\\Domino\\ImageDb.nsf\\500-99-9o9\\$File\\abc.tif";
// Create an instance of WebClient
WebClient client = new WebClient();
string filename
= "c:\\test.tif";
client.DownloadFile(url,filename);
But the file which is downloaded is of 4kb instead of 22kb and when i try to open it, its says its in improper/invalid format. Any guesses what is going wrong?

Using Fiddler, you will see that the 4kb file is the authentication HTML page that Domino automatically presents when an un-authenticated request for content is made via HTTP and the particular resource requested is not accessible anonymously.
In this case, it sounds like when you request this file resource in Domino, you will need to authenticate.
You can do this by providing a valid LTPToken in the request header, which is issued by the Domino server once you have authenticated. Alternatively, if authentication is not possible you can make the database ACL, and document accessible to "anonymous" users. Although not specifically C# code, these links will help you understand about LTPA on Domino, here, here and here

Related

Data Factory can't download CSV file from web API with Basic Auth

I'm trying to download a CSV file from a website in Data Factory using the HTTP connector as my source linked service in a copy activity. It's basically a web call to a url that looks like https://www.mywebsite.org/api/entityname.csv?fields=:all&paging=false.
The website uses basic authentication. I have manually tested by using the url in a browser and entering the credentials, and everything works fine. I have used the REST connector in a copy activity to download the data as a JSON file (same url, just without the ".csv" in there), and that works fine. But there is something about the authentication in the HTTP connector that is different and causing issues. When I try to execute my copy activity, it downloads a csv file that contains the HTML for the login page on the source website.
While searching, I did come across this Github issue on the docs that suggests that the basic auth header is not initially sent and that may be causing an issue.
As I have it now, the authentication is defined in the linked service. I'm hoping that maybe I can add something to the Additional Headers or Request Body properties of the source in my copy activity to make this work, but I haven't found the right thing yet.
Suggestions of things to try or code samples of a working copy activity using the HTTP connector and basic auth would be much appreciated.
The HTTP connector expects the API to return a 401 Unauthorized response after the initial request. It then responds with the basic auth credentials. If the API doesn't do this, it won't use the credentials provided in the HTTP linked service.
If that is the case, go to the copy activity source, and in the additional headers property add Authorization: Basic followed by the base64 encoded string of username:password. It should look something like this (where the string at the end is the encoded username:password):
Authorization: Basic ZxN0b2njFasdfkVEH1fU2GM=`
It's best if that isn't hard coded into the copy activity but is retrieved from Key Vault and passed as secure input to the copy activity.
I suggest you try to use the REST connector instead of the HTTP one. It supports Basic as authentication type and I have verified it using a test endpoint on HTTPbin.org
Above is the configuration for the REST linked service. Once you have created a dataset connected to this linked service you can include it in you copy activity.
Once the pipeline executes the content of the REST response will be saved in the specified file.

Restygwt download byte[]

I have only an array of byte on the client side.
Another server send me JSON
{
report - byte[]
}
I am looking for ways to save byte [] in browser
Send them to server or I can download from client side.
I can not find any solution at all.
So my question "Is it possible to save with restygwt byte [] an how???"
It is not possible to save the file directly from Resty.
https://github.com/resty-gwt/resty-gwt/issues/341
The most common workarounds to download files using AJAX are not using AJAX at all.
You can simply change the URL (using window.location) or (using javascript) create or;
create a form (using JS) and post that form.
In my projects, I simple create a URL to my REST endpoint attaching any query parameters needed and use it as the href to a link.
For instance, if your RestyGwt endpoint points to /entity/1/bytes
just do
new Anchor("Download", "/entity/1/bytes");
your endpoint must produce a downloadable file type say:
#Produces("text/txt")

How to intercept multipart/form data in fiddler and access a binary file which is a part of the request

I am trying to intercept requests send to a server from my mobile device. There is this post request which will upload payload to the server and the request has a file of type .pb, which i cant read in fiddler. Is there a way to get hold of the file ?
It's not clear what "i cant read in fiddler" means.
Use Fiddler's HexView request inspector to inspect the POST body. You can select the bytes of the file upload and choose Save bytes to save the file out to your desktop.

Check if Sailjs backend is getting a legit req from the frontend without any authentication system

I do not want my users to authenticate. But I do not anyone to steal my data. So my goal is to only serve the people who make a req from the front end of the app. How can I do this ?
Is there a built in function that I'm missing ? I know that there are session id generated, but not sure how to incorporate the session id to this situation.
Thanks
By using the term "front end" I would assume that you have a client requesting data in the form of JSON/XML or HTML templates. My first suggestion to get your answer is to be much more descriptive in your question. It is very hard to answer without knowing how your client is designed.
Assuming your client is written in html/js and run in a browser then I would suggest that you serve a static file (in the form of a .js file or a <script></script> tag inside an html file) that generates a token. You can pass this token back to your server for validation on every request for data. This means that only your app (front-end) can be the only thing that requests data from your api (back-end).

Force the browser to send some HTTP request header

I need to include some secure (BASIC authentication) application.
when I open the application URL in the browser, the browser asks me to enter your credentials ...
what I know is that:
The browser ask the server to get
some URL -- the url of the app
The server checks the request header
for the Authentication header and
didn't find it
The server sends 401 to the
browser back
The browser interpret this response
code into a message dialog that
shows to me asking me to enter the
username/password to send back to
the server in the Authentication
request header
So far... so good, I can write some page (in JSP) that send this required http request header to the request that is calling this page..
So I'll call this application through my page..
The problem here is, this application (in fact a GWT application) contains a reference to some Javascript and CSS files that is coming from the server that hosts this application. the application page that I import looks like:
<html>
<link href="http://application_host/cssfile.css" />
<link href="http://application_host/javascriptfile.js" />
.....
</html>
So, again I found the application asks me for the authentication crenditals for the css and js files!
I am thinking of many solutions but don't know the applicability of each
One solution is to ask the browser
(via Javascript) to send the request
header (Authentication) when he
asks the server for the js and css
files
please give me your opinions about that... and any other suggestions will be very welcomed.
Thanks.
I think you're running into some weirdness with how your server is configured. Authentication happens in context of a authentication realm. Your assets should either be in the same authentication realm as your page, or (more likely) should not require authentication at all. The browser should be caching credentials for the given realm, and not prompt for them again.
See the protocol example on http://en.wikipedia.org/wiki/Basic_access_authentication
Judging from your story, something tells me your problem is with the authentication method itsef. Not how to implement it. Why do you want to bother with the request header so much?
As far as i know, you can configure your container (ie Tomcat) to force http authentication for certain urls. Your container will make sure that authentication has taken place. No need to set http headers yourself whatsoever.
Perhaps you can explain a bit better what you are trying to achieve, instead of telling implementation details?
Why css & js files are kept in protected area of server? You need to place files into public area of your server. If you don't have public area, so you nead to prpvide for it. how to do it depends from serverside software architecture & configuration.