PHP Classes

File: examples/kernel/net/TFTPHandler/compressFile.php

Recommend this page to a friend!
  Packages of Christos Drogidis   Ascoos OS   examples/kernel/net/TFTPHandler/compressFile.php   Download  
File: examples/kernel/net/TFTPHandler/compressFile.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Ascoos OS
A PHP Web 5.0 Kernel for decentralized web and IoT
Author: By
Last change: Update of examples/kernel/net/TFTPHandler/compressFile.php
Date: 7 months ago
Size: 1,585 bytes
 

Contents

Class file image Download
<?php
/**
 * @ASCOOS-NAME : Ascoos OS
 * @ASCOOS-VERSION : 26.0.0
 * @ASCOOS-SUPPORT : support@ascoos.com
 * @ASCOOS-BUGS : https://issues.ascoos.com
 *
 * @desc <English> Demonstrates compressing a file using the compressFile method.
 * @desc <Greek> ??????????? ?? ???????? ??????? ??????????????? ?? ?????? compressFile.
 *
 * @since PHP 8.2.0
 */

use ASCOOS\OS\Kernel\Net\TFTPHandler;

global
$conf, $AOS_CACHE_PATH, $AOS_LOGS_PATH, $AOS_TMP_PATH;

// <English> Initialize properties array with configuration
// <Greek> ???????????? ?????? ????????? ?? ??????????
$properties = [
   
'ftp' => [
       
'protocol' => 'sftp',
       
'host' => 'example.com',
       
'port' => 22,
       
'username' => 'user',
       
'password' => 'pass'
   
],
   
'logs' => ['useLogger' => true, 'dir' => $AOS_LOGS_PATH],
   
'cache' => ['cacheType' => 'file', 'cachePath' => $AOS_CACHE_PATH]
];

// <English> Create a new TFTPHandler instance
// <Greek> ?????????? ???? instance ??? TFTPHandler
$ftpHandler = new TFTPHandler($properties);

// <English> Compress a file
// <Greek> ???????? ???????
if ($ftpHandler->compressFile($AOS_TMP_PATH . '/source.txt', $AOS_TMP_PATH . '/source.zip', 'zip')) {
    echo
"File compressed successfully\n";
} else {
    echo
"Failed to compress file\n";
}

// <English> Free resources
// <Greek> ???????????? ?????
$ftpHandler->Free($ftpHandler);
?>