How to retrieve file from FTP server in Flutter - dart

I was trying to download files from FTP server to mobile devices but could not find any plugins to do so. How to connect devices to FTP Server and download the files using Flutter?

you can use SSH library
//Connect SFTP: #
await client.connectSFTP();
//List directory: #
var array = await client.sftpLs("/home");

Related

Retrieve file from keyvault instead of secure files in InstallAppleCertificate task on azure pipeline

According to the documentation of the InstallAppleCertificate task, there is a certSecureFile parameter that looks for the certificate in the "Secure Files":
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/install-apple-certificate?view=azure-devops
However in my organization I don't have the permission to upload secure files:
Any other way to select a certificate that isn't uploaded to "Secure Files" for this task?
They did gave me a separate keyvault which I can perfectly link to the pipeline build and get files/secrets from in bash scripts. Yet this InstallAppleCertificate task doesn't allow me to use those instead. I wouldn't even mind to put the certificate in my source repo (I know I shouldn't do this).
The certSecureFile field in InstallAppleCertificate task needs to use the .p12 file in secure file.
I am afraid that files that are not in the secure file cannot be used.
Based on my test, when I use the file from local machine, it will show the following error:
This means that before running the build, it will retrieve the files in the secure file. And the file needs to exist in secure file.
Since you could get the files/secrets , you could try to install the Apple Certificate(.p12 file) via script.
security import ./xxx.p12 -P secretPassword
Here is a thread about install .p12 or .cer in console macos.

How to deploy flutter web on server?

I was learning Flutter web. Now I want to deploy this code in the real server.
The flutter code here: in the lib folder
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter layout demo',
home: Scaffold(
appBar: AppBar(
title: Text('Flutter layout demo'),
),
body: Center(
child: Text('Hello World'),
),
),
);
}
}
How can I deploy this code on the server ? I am new on the Flutter web.
[UPDATE]
To create a production build for web, you can now directly run flutter build web command similar to other platforms (android and ios)
and you will see build/web folder generated with the assets folder and you can simply deploy it on your server.
[OLD ANSWER STEP 1 & 2 No longer required ]
you need to do a production build by using a webdev tool,
To install webdev you need a pub tool.
so go to the location where you have dart SDK installed and inside the bin folder you should have a pub batch file. You need to provide the bin folder's path to the environment variable in order to use pub from cmd.
open cmd/terminal run the below command to install webdev
pub global activate webdev
now go to the root folder of your project and do a build in release mode
flutter build web
you should see a build folder (/build/web) in the root directory, just copy that folder and host it on a web server.
I used the same way to deploy it to GitHub pages here's how in detail guide.
Some useful link: https://dart.dev/tools/webdev#build
Here's the running flutterweb app
You can deploy your flutter web app in a shared hosting with Nodejs or in VPS server with Python Follow this Medium Blog Post
After you build your flutter web app with "flutter build web" and you want to host it in a shared hosting plan prepare your nodejs app as a simple server for your flutter web app here is sample code
app.js
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public-flutter')));
module.exports = app;
package.json
{
"name": "flutter-web-app",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.16.1",
"morgan": "~1.9.1"
}
}
Create a folder and name it (“public-flutter”) and then put your flutter web app in the folder you have just created so nodejs can serve it through his server if you are in a shared hosting just continue with the Blog Post here
and if you are in a VPS server then run this command if you want to server the nodejs app
node app.js
or if you don't want nodejs just use python in your flutter web app to serve it as a simple http server with this command
nohup python -m SimpleHTTPServer 8000 &
Just make sure you are in your web app folder when you run the command. “nohub” will let the command keep running even if you closed the SSH session on Linux .
Or you can server your app through Dart pub/webdev tools by using the dhttpd package.
if you want to use your own server over web e.q your virtual private host or other host over net :
go to the root folder of your project and do a build in release mode flutter build web,then
upload (/build/web)directory to your server ,
you can follow this link and configure IIS on windows server.
Here is the simple way to deploy your flutter web application on amazon web server.
Following is the simple process i follow.
Build flutter web: flutter build web —release
Create instance on aws ec2 server: mean allocate some memory for
your website on server. Instance is the virtual server in aws cloud.
Connect to your server(instance) with the help of putty :
Install Vesta control panel on your server. (you can install other control panel
too if you don't like vesta).
Upload your content(website) on server.(With the help of
FileZilla you can easily upload
your website content on server)
Here is the simple video tutorial:
https://youtu.be/htuHNO9JeRU
Nota Bene - Using flutter 2.0 as of today, I am seeing a bug where the images are not uploaded. Performance is also not the best as of
today. Bookmark this and I will update with workarounds.
One solution for those who use VPS/Shared hosting of any kind:
Open the local build folder
Compress (zip) the web folder
Upload the web.zip file (ftp or file manager)
On your server (for example on cPanel choose Extract from the File
Manager)
Rename the web folder to whatever you like
Note that if you are not using the website's root directory you must rename the
folder in index.html from "/" to "/web/" (to match the name above, see eg.)
If you are using the website root folder make sure you move all the files
from inside of /web into your / website's root folder (not your
server)
eg.
<base href="/"> to <base href="/web/">
Update for missing images issue
tldr; Two issues - In pubspec.yaml I forgot to uncomment the assets folder and when built for web, the images were placed one
folder below the assets folder. Editing the pubspec.yaml and moving
the images folder up one level (after building for the web) solved the
issue.
My flutter project folder has an assets/images folder in the project root. After not seeing the image online (it was visible during debugging), I found that running flutter build web --release caused my assets folder to be recreated within build/web/assets/assets/images. My code correctly referenced assets/images/file.png. I just moved the images folder up one level when deploying to the web. So my web server root now has assets/images/name.png and the image is showing fine.
Solution - The fix for this was to use the proper structure for assets which is to create top level folders for (images and
google_fonts) in the flutter project root. Then the compiler builds
the web project correctly. My code references image assets as
images/name.png. Pubspec.yaml should reference the assets: as
- images/ and - google_fonts/
If it's a Firebase project you can use Firebase Hosting.
It will ask you to install Firebase Tools on your system and you will have to initialize it on the root folder of your project.
Then you just have to:
flutter build web
firebase deploy
and refresh browser (maybe with ctrl + F5 or ctrl + shift + r)

Creating laravel apps without internet connection

Does laravel 5.1 work without internet connection?
I like to create a laravel new application
when i execute laravel new test (with intenet connection) it works well;
but when i execute similar command in the same directory (new anotherName) without internet connection it doesn't work and the nest error message is shown
[GuzzleHttp\Exception\RequestException]
Error creating resource. [url] http://cabinet.laravel.com/latest.zip [type]
2 [message] fopen(http://cabinet.laravel.com/latest.zip): failed to open s
tream: php_network_getaddresses: getaddrinfo failed: Name or service not kn
own [file] /home/<Myname>/.composer/vendor/guzzlehttp/guzzle/src/Adapter/Str
eamAdapter.php [line] 367
Is there a solution because i can't work online always?
When you use the laravel installer it fetches the latest version from the server. One solution would be to initialise a Laravel project, then add it to git version control and then when offline checkout the project to a new folder. You'd have to manually choose a new app key (I think). You will also not be able to composer require or npm install any new packages while offline.
Once you have created it though it should run offline (unless your views are sourcing assets from, say, bootstrap or jQuery CDNs).
Composer 2+:
COMPOSER_DISABLE_NETWORK=1 laravel new myapp
Troubleshooting:
Check your composer version: composer --version - you may have to update to the latest version with composer self-update;
Check you have a global cache: echo $COMPOSER_HOME - you may have to create a ~/.composer and set export COMPOSER_HOME="${HOME}/.composer" to your ~/.bashrc or ~/.zshrc - don't forget to close and open your terminal to apply the changes;
If you get this error https://repo.packagist.org could not be fully loaded (Network disabled, request canceled: https://repo.packagist.org/packages.json), package information was loaded from the local cache and may be out of date, the laravel packages are not in the global cache. Run the command with internet enabled to download the files.

How to list local directory files from server with Ruby on rails

I am trying to list all the video file in local system. I have used this code to get it.
def brows_video_files_from_a_directory
if params[:file_directory]
two_dimentional_array = []
combined = []
file_directory = params[:file_directory]
Dir.glob(file_directory + "/*.{mov,mp4,flv,mkv,avi,wmv,mpg,mpeg,3gp}").each.with_index do |item, index|
#file_details = two_dimentional_array << create_array_of_data(item, combined)
end
end
end
http://i.stack.imgur.com/M7jIE.png <- Check this screenshot
it works fine in my local system (http://localhost:3000/) but after push to the server it trying to fetch the directory from the server not from the local machine , is there any way to list all the files from local machine
The server code is run on the server machine, and your code only allows to read files from a local filesystem.
If you want to read files from a computer different from the server, you need to use a protocol that allows to access the filesystem of a remote computer.
You can make a SSH connection from your server to your local computer, and you will be able to run commands though the SSH connection.
You can also use other protocols, such as FTP, SMB, ...

How can i upload a zip folder on FTP server from my local drive using put command of ant tool

in my lacal drive i created a zip folder whom i want to upload at FTP server by using the put command of ANT.pls give me some idea...
Don't know if you're meaning this but check the Apache Commons library.
http://commons.apache.org/net/index.html
Would be something like:
import org.apache.commons.net.ftp.*;
...
...
FTPClient ftp = new FTPClient();
ftp.connect(FTP_HOST);
ftp.login(FTP_USER, FTP_PASS);
ftp.changeWorkingDirectory(FTP_PATH);
ftp.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
FileInputStream fis = new FileInputStream(fileName);
ftp.storeFile(fileName,fis);
ftp.logout();

Resources