How I can download a file from a server using WebClient ad Server.MapPath and dowload it to Desktop?
Example:
WebClient Client= nre WebClient();
Client.DownloadFile(Server.MapPath("~/Files/")+fileRoute,#"~/Desktop/"+fileName);
Related
Trying to read file from server where CRM is installed. When I am reading the file from the server, plugin throws an error "Directory not found".
Entity attachment = new Entity("activitymimeattachment");
FileStream stream = File.OpenRead(fileName);
byte[] byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);
stream.Close();
// Encode the data using base64.
string encodedData = System.Convert.ToBase64String(byteData);
attachment["subject"] = "Attachment";
attachment["filename"] = "emailstatement.pdf";
//byte[] fileStream = Encoding.ASCII.GetBytes(fileName);
attachment["body"] = encodedData;
attachment["mimetype"] = #"application\pdf";
attachment["attachmentnumber"] = 1;
attachment["objectid"] = new EntityReference("email", emailguid);
attachment["objecttypecode"] = "email";
service.Create(attachment);
Can anyone help me to read file from server using plugin?
Thank you.
Makes sure your plugin is registered outside of the sandbox (in partial trust). Its an option in the plugin registration tool.
Plug-in isolation, trusts, and statistics
Microsoft Dynamics 365 (online & on-premises) support the execution of
plug-ins and custom workflow activities in an isolated environment. In
this isolated environment, also known as a sandbox, a plug-in or
custom activity can make use of the full power of the Microsoft
Dynamics 365 SDK to access the organization web service. Access to the
file system, system event log, certain network protocols, registry,
and more is prevented in the sandbox.
We can use Matlab's built in ftp function to authenticate to the FTP server as follows:
HOST = 'a.b.c.d';
USER = 'hello';
PASS = 'world';
conn = ftp(HOST, USER, PASS);
However, I have now a FTP server where the authentication goes through a private key file (generated by PuTTY). How can I use this in this context to Authenticate? Using FileZilla you can select the Logon Type "Key File" (I tested and this worked).
After some research I found a file exchange package that allowed you to use a private key to authenticate to the SFTP.
See Secure FTP (SSH/SFTP/SCP).
However, I am open to hear about other solutions (e.g. by Matlab) if they exist.
I am using Elasticsearch in one project an locally my client is located at localhost:9200, but when I am on dev environment my Elasticsearch client is at https://elasticsearch.eu:443/v1/elastic. When i am creating the Java client I use:
RestClient restClient =RestClient.builder( new HttpHost(Host, port)).build(). Which is the correct way to set the Host and port for the second URL, since we have an extra path?
In the version 7.17, according to Java Low Level REST Client - Initialization
RestClient restClient = RestClient.builder(
new HttpHost("localhost", 9200, "http"),
new HttpHost("localhost", 9201, "http")).build();
I have online/offline project.
I need to download wav/ogg/mp3 file from Application.persistentDataPath on WebGL platform.
I tried www/webrequest.
For example - WWW("file://" + Application.persistentDataPath + filePath);
But always get error: Failed to load: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Could you help me?
P.S. From remote server works fine.
You can not load local files in a browser as it's a security risk. If you could then a webpage could read your hard drive and steal all your files.
If you're just testing you can run a local server.
If you want to let the user supply a file you can let them choose a file
I am trying to request JSON data from a PHP script in my Android app.
The whole thing works well when I'm directly connecting my mobile phone and directly access the "real" Internet webserver. However, it doesn't work at all using the emulator and localhost (WAMP installation). Running the script directly on the local webserver, again, gives me the expected results- only if I am calling it on the same machine using the emulator, the troubles begin.
Here are the combinations I have tried so far (the scripts are located in the subdirectory "zz" of the root):
private static String url_all_venues = "http://10.0.2.2/zz/pullvenuesjson.php";
or
private static String url_all_venues = "http://10.0.2.2:80/zz/pullvenuesjson.php";
leads to the following exception: E/JSON Parser(657): Error parsing data org.json.JSONException: Value
When I'm trying the following:
private static String url_all_venues = "http://10.0.2.2:8080/zz/pullvenuesjson.php";
the code runs 'forever' and I'm getting a timeout error after about 5 minutes.
Any idea how to fix that so I can also test my app on my local webserver / the emulator? Most probably the problem is in my local Apache configuration, but then, I'm not sureā¦
EDIT:
Here is some of the code that seems to trigger the error:
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
"url" is the one mentioned above. As mentioned in my comment below, it looks as if the problem comes from the local WAMP webserver not responding appropriately, since the code works fine when I'm directly accessing the "real" server via the Internet (i.o.w, do nothing else than changing the URL to the Internet address of the php script). The odd thing is that the script also works fine when I run it locally, but NOT through the emulator.
I finally figured it out! I logged the transferred data using Log.d(..) and found out that the username/password combination was not valid as I didn't check for the localhost condition... The script and app retrieves the data just fine now on both, localhost and the web. Thanks for your inquiries which helped me to get down to the root of the error!
[Answered myself in order to avoid the Q showing up as unanswered]