Hey team, I am working on one issue (#4001) since last week, I need to implement rzip Compression support in Appwrite. https://github.com/appwrite/appwrite/issues/4001
But in the initial phase only, I'm not able to find any native support for rzip Compression technique in Appwrite.
I can only be able to do is installing rzip manually in local machine and compress and decompress the files using exec command from php.
If it's not the solution, can you provide me any support documentation for rzip in PHP if there's any native support available for it.
Looking forward to learn!
can someone look into it @Haimantika @Christy Jacob ?
I've found this,
https://rzip.samba.org/ftp/rzip/rzip-2.1.tar.gz
here, I will first download it, and will exract it.
then installing and stuff.
after installtion I'll be trying to access rzip compression using exec function in php.
so would that be fine ?
As an example:
<?php
// Function to compress data using rzip
function rzipCompress(string $data): string
{
// Write the data to a temporary file
$tempFile = tempnam(sys_get_temp_dir(), 'rzip_');
file_put_contents($tempFile, $data);
// Execute the rzip command to compress the file
$compressedFile = $tempFile . '.rz';
$command = "rzip $tempFile -o $compressedFile";
shell_exec($command);
// Read the compressed data from the file
$compressedData = file_get_contents($compressedFile);
// Remove temporary files
unlink($tempFile);
unlink($compressedFile);
return $compressedData;
}
// Function to decompress data using rzip
function rzipDecompress(string $data): string
{
// Write the data to a temporary file
$tempFile = tempnam(sys_get_temp_dir(), 'rzip_');
file_put_contents($tempFile, $data);
// Execute the rzip command to decompress the file
$decompressedFile = $tempFile . '_decompressed';
$command = "rzip -d $tempFile -o $decompressedFile";
shell_exec($command);
// Read the decompressed data from the file
$decompressedData = file_get_contents($decompressedFile);
// Remove temporary files
unlink($tempFile);
unlink($decompressedFile);
return $decompressedData;
}
// Example usage
$originalData = "This is some test data that we want to compress using rzip.";
$compressedData = rzipCompress($originalData);
echo "Compressed Data: " . $compressedData . "\n";
$decompressedData = rzipDecompress($compressedData);
echo "Decompressed Data: " . $decompressedData . "\n";
?>
@Core Can you please look into this ?
My primary concern is to use cmd line using exec.
curl https://rzip.samba.org/ftp/rzip/rzip-2.1.tar.gz --output rzip-2.1.tar.gz &&
tar -xzf rzip-2.1.tar.gz &&
cd rzip-2.1 &&
mv aclocal.m4 config.m4 &&
phpize &&
./configure &&
make &&
make install
Above is the script that I want to use in installing rzip. can you please verify ? because There's no standard documentation or native support available for rzip in php
@Haimantika !!
Hi, just reading it, I do not have experience working with it, so I have asked the team to see if anyone can help.
@Vashishth Patel the easiest way is to refer to PRs that have already been merged https://github.com/utopia-php/storage/pull/59
This PR is very close to what you need to do in your case as well
Please do not tag groups or people like this as it can be very disruptive
hmmm i can't seem to find a rzip php extension, though 😬
Yes, my point is that only, there's no native support available for it.
So that's why I found this potential solution.
Can we use exec in the code, To compress and decompress the file ?
Just, give me your final thoughts on it, I'll make the PR asap!!
Any Updates ?
Can someone guide me in this @Christy Jacob @Steven ? Atleast give me some resources or try to ans my questions, so I can move forward!!
Honestly, you probably won't be able to complete this unless you can implement the rzip compression using php or some other extension. I'm not a fan of executing a shell command
But, would that be fine if I will go with executing shell command ?
Atleast I can give it a try !!
Executing shell commands is often slower. In addition, you can open yourself to security problems if not handled properly
We did it in the past in some specific places, but the shell execution has a big overhead. I think @bradleySchofield use this (https://crates.io/crates/ext-php-rs) in the past to build a native php extension using rust native libraries.
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.
- Seed db
hello there... is this correct way to seed appwrite