Download File from HTTPS to computer using SSIS - https

Please I am trying to download a File from an HTTPS website.
i have created an HTTP Manager to connect to the website with my password and Username.
Now what do i do next to be able to the file with a certain format and dump in a specific folder on my computer?

Here what you are looking for
http://www.sqlis.com/post/Downloading-a-file-over-HTTP-the-SSIS-way.aspx

How about something like:
Dim wc As WebClient = New WebClient()
wc.Credentials = New System.Net.NetworkCredential("user-id", "password", "domain")
wc.DownloadFile("https://www.portal.zzz.com/sites/Document area/fff.xlsx", "C:\fff.xlsx")

Related

JMeter: How to access a remote Cloud directory in JMeter?

I need to access a remote cloud directory ( microsoft azure) to list the files in the folder. I also need to move some of the files to another folder in the cloud directory ( cut and paste ).
I found a few answers which spoke about using a Beanshell Sampler and a Foreach controller to get the files in a directory (This was for the folder structure on my local machine). I was able to check the results using a Debug Sampler and a view results tree. However, I am not sure how to use this for a Cloud directory.
I also found answers around using a Directory Listing Config Plugin, this works well with the local directory as well. But I am unable to pass the path to the cloud directory.
Is there a way to access the cloud directory? I am fairly new to JMeter.
Please Help. Thank You.
If you're talking about Azure Files - it can be accessed either via NFS protocol or SMB protocol.
None of the protocols is supported by JMeter or any plugins so you will have to use JSR223 Sampler and write some custom Groovy code using the relevant Java library like EMC NFS Java Client or JCIFS. For the latter one example code can be found in How to Load Test SMB/CIFS with JMeter, example adaptation just in case:
import jcifs.smb.NtlmPasswordAuthentication
import jcifs.smb.SmbFile
String url = "smb://path/to/your/cloud/directory";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "username", "password");
SmbFile smbFile = new SmbFile(url, auth);
SmbFile[] files = smbFile.listFiles("*");
for (int i = 0; i < files.length; i++) {
log.info("File + " + i + ": " + files[i].getName());
}

Xamarin Android share PDF. Permission denied for the attachment [duplicate]

My app creates mails with attachments, and uses an intent with Intent.ACTION_SEND to launch a mail app.
It works with all the mail apps I tested with, except for the new Gmail 5.0 (it works with Gmail 4.9), where the mail opens without attachment, showing the error: "Permission denied for the attachment".
There are no useful messages from Gmail on logcat. I only tested Gmail 5.0 on Android KitKat, but on multiple devices.
I create the file for the attachment like this:
String fileName = "file-name_something_like_this";
FileOutputStream output = context.openFileOutput(
fileName, Context.MODE_WORLD_READABLE);
// Write data to output...
output.close();
File fileToSend = new File(context.getFilesDir(), fileName);
I'm aware of the security concerns with MODE_WORLD_READABLE.
I send the intent like this:
public static void compose(
Context context,
String address,
String subject,
String body,
File attachment) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(
Intent.EXTRA_EMAIL, new String[] { address });
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, body);
emailIntent.putExtra(
Intent.EXTRA_STREAM,
Uri.fromFile(attachment));
Intent chooser = Intent.createChooser(
emailIntent,
context.getString(R.string.send_mail_chooser));
context.startActivity(chooser);
}
Is there anything I do wrong when creating the file or sending the intent? Is there a better way to start a mail app with attachment? Alternatively - has someone encountered this problem and found a workaround for it?
Thanks!
I was able to pass a screenshot .jpeg file from my app to GMail 5.0 through an Intent. The key was in this answer.
Everything I have from #natasky 's code is nearly identical but instead, I have the file's directory as
context.getExternalCacheDir();
Which "represents the external storage directory where you should save cache files" (documentation)
GMail 5.0 added some security checks to attachments it receives from an Intent. These are unrelated to unix permissions, so the fact that the file is readable doesn't matter.
When the attachment Uri is a file://, it'll only accept files from external storage, the private directory of gmail itself, or world-readable files from the private data directory of the calling app.
The problem with this security check is that it relies on gmail being able to find the caller app, which is only reliable when the caller has asked for result. In your code above, you do not ask for result and therefore gmail does not know who the caller is, and rejects your file.
Since it worked for you in 4.9 but not in 5.0, you know it's not a unix permission problem, so the reason must be the new checks.
TL;DR answer:
replace startActivity with startActivityForResult.
Or better yet, use a content provider.
Use getExternalCacheDir() with File.createTempFile.
Use the following to create a temporary file in the external cache directory:
File tempFile = File.createTempFile("fileName", ".txt", context.getExternalCacheDir());
Then copy your original file's content to tempFile,
FileWriter fw = new FileWriter(tempFile);
FileReader fr = new FileReader(Data.ERR_BAK_FILE);
int c = fr.read();
while (c != -1) {
fw.write(c);
c = fr.read();
}
fr.close();
fw.flush();
fw.close();
now put your file to intent,
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tempFile));
You should implement a FileProvider, which can create Uris for your app's internal files. Other apps are granted permission to read these Uris. Then, simply instead of calling Uri.fromFile(attachment), you instantiate your FileProvider and use:
fileProvider.getUriForFile(attachment);
Google have an answer for that issue:
Store the data in your own ContentProvider, making sure that other apps have the correct permission to access your provider. The preferred mechanism for providing access is to use per-URI permissions which are temporary and only grant access to the receiving application. An easy way to create a ContentProvider like this is to use the FileProvider helper class.
Use the system MediaStore. The MediaStore is primarily aimed at video, audio and image MIME types, however beginning with Android 3.0 (API level 11) it can also store non-media types (see MediaStore.Files for more info). Files can be inserted into the MediaStore using scanFile() after which a content:// style Uri suitable for sharing is passed to the provided onScanCompleted() callback. Note that once added to the system MediaStore the content is accessible to any app on the device.
Also you can try set permissions for your file:
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
And finally you can copy/store your files in external storage - permissions not needed there.
I tested it and I found out that it was definitely private storage access problem.
When you attach some file to Gmail (over 5.0) do not use the file from private storage such as /data/data/package/. Try to use /storage/sdcard.
You can successfully attach your file.
Not sure why GMail 5.0 doesn't like certain file paths (which I've confirmed it does have read access to), but an apparently better solution is to implement your own ContentProvider class to serve the file. It's actually somewhat simple, and I found a decent example here: http://stephendnicholas.com/archives/974
Be sure to add the tag to your app manifest, and include a "android:grantUriPermissions="true"" within that. You'll also want to implement getType() and return the appropriate MIME type for the file URI, otherwise some apps wont work with this... There's an example of that in the comment section on the link.
I was having this problem and finally found an easy way to send email with attachment. Here is the code
public void SendEmail(){
try {
//saving image
String randomNameOfPic = Calendar.DAY_OF_YEAR+DateFormat.getTimeInstance().toString();
File file = new File(ActivityRecharge.this.getCacheDir(), "slip"+ randomNameOfPic+ ".jpg");
FileOutputStream fOut = new FileOutputStream(file);
myPic.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
fOut.close();
file.setReadable(true, false);
//sending email
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"zohabali5#gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Recharge Account");
intent.putExtra(Intent.EXTRA_TEXT, "body text");
//Uri uri = Uri.parse("file://" + fileAbsolutePath);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(Intent.createChooser(intent, "Send email..."),12);
}catch (Exception e){
Toast.makeText(ActivityRecharge.this,"Unable to open Email intent",Toast.LENGTH_LONG).show();
}
}
In this code "myPic" is bitmap which was returned by camera intent
Step 1: Add authority in your attached URI
Uri uri = FileProvider.getUriForFile(context, ""com.yourpackage", file);
Same as your manifest file provide name
android:authorities="com.yourpackage"
Step 2`; Add flag for allow to read
myIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

How to download file from google drive api with service account?

Hello google hackers!
I am using Drive Service app and uploaded file successfully like this:
require 'googleauth'
require 'google/apis/drive_v2'
Drive = Google::Apis::DriveV2
upload_source = "/User/my_user_name/hacking.txt"
drive = Drive::DriveService.new
# Drive::AUTH_DRIVE is equal to https://www.googleapis.com/auth/drive
drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE])
file = drive.insert_file({title: 'hacking.txt'}, upload_source: upload_source)
file has a lot of properties, like this:
download_url
But when I try to open this download_url in browser it shows me blank screen. Why I can't download it?
I guess, that may be there are permission problems? But the scope is correct, and uploading is successful...
The answer is simple - we cannot download it from file object, we must send another get request, just download it like this:
drive.get_file(file.id, download_dest: '/tmp/my_file.txt')

Amazon S3 client connect through proxy - putObject getting NullPointerException

I've got this simple piece of code which is trying to upload a file to Amazon S3 via a proxy. This is the code:
BasicAWSCredentials basicCred = new BasicAWSCredentials("my_access_key", "my_secret_key");
ClientConfiguration clientCfg = new ClientConfiguration();
clientCfg.setProtocol(Protocol.HTTP);
//setup proxy connection:
clientCfg.setProxyHost("192.168.2.12");
clientCfg.setProxyPort(80);
AmazonS3 s3 = new AmazonS3Client(basicCred, clientCfg);
String bucketName = "mybucket";
String key = "/test/Capture.JPG";
File file = new File("d:/Test_Data/Capture.JPG");
System.out.println("Uploading a new object to S3 from a file");
s3.putObject(new PutObjectRequest(bucketName, key, file));
However this is the error I got from running the program:
Exception in thread "main" java.lang.NullPointerException
at com.amazonaws.util.BinaryUtils.fromHex(BinaryUtils.java:69)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1066)
at javaapplication8.JavaApplication8.main(JavaApplication8.java:48)
Java Result: 1
I'm using the latest aws 1.3.8 sdk from amazon. The proxy is set up in another PC next to me and it's just a simple Javascript proxy (http://www.catonmat.net/http-proxy-in-nodejs/)
I can't figure it out why. Somebody can help me, please?
here is another approach,
ClientConfiguration config = new ClientConfiguration();
config.setProtocol(Protocol.HTTPS);
config.setProxyHost("YOUR_PROXY_IP");
config.setProxyPort(YOUR_PROXY_PORT);
BasicAWSCredentials creds = new BasicAWSCredentials("YOUR_KEY", "YOUR_SECRET");
s3Client = AmazonS3ClientBuilder.standard()
.withClientConfiguration(config)
.withRegion(Regions.US_EAST_2)
.withCredentials(new AWSStaticCredentialsProvider(creds))
.build();
I ran into this issue as well. I stepped through everything in a debugger and found that the cause of the problem is the Amazon S3 client code expecting a header tag called "ETag", but the response contains "Etag", with a lowercase "t".
The headers are put into a Map<String,String>, so when the Amazon S3 client code calls get("ETag"), it gets back null, which is then fed into the hexData() method and blows up.
This seems to happen to a number of people using non-Amazon S3 services or accessing Amazon's AWS S3 service through a web proxy.
I don't know of a fix other than grabbing the Amazon client source, changing the Headers.ETAG value to "Etag" and building the JAR yourself.
Change the protocol to HTTPS.
$clientCfg.setProtocol(Protocol.HTTPS);

Download an EXE file using Window Application

I write a code to check an update for my application which is working fine.
Now what i wants to do is, I have an URL of my update. I wants to save that file in my temp folder silently without user notification(means once user click on "Yes" button of an Update dialog) and then install that file in machine.
I tried a way using "Process.Start" but it opens IE in user's machine and then download the file which i don't want.
You need to programatically download the file.
Use WebRequest and WebResponse, open a stream and save it to a file.
WebRequest req = WebRequest.Create("YOUR URL");
WebResponse resp = req.GetResponse();
Stream s = resp.GetResponseStream();
// Now save this stream to a file
If you are using Java, you could use the apache commons httpclient library to download the file.

Resources