We are excited to announce the release of the latest versions of the Filestack SDKs for PHP and Python. This upgrade provides developers with access to new features and performance improvements and ensures compatibility with the latest PHP and Python versions. It also fixes crucial user-reported issues with previous PHP and Python versions.
What’s new
PHP SDK updates
The Filestack PHP SDK provides PHP developers with three classes to interact with the Filestack API:
FilestackClient
– for easy file upload (createsFilelink
objects)Filelink
– for file handling (downloading, converting, etc.)FileSecurity
– for applying policy and signature values to your API calls
With the latest update, you can use these classes in your PHP 8 projects without known issues.
The latest version of the PHP SDK includes new features, bug fixes, performance improvements, and support for the latest PHP versions. Developers can now take advantage of new features and enhancements to improve their file management workflows.
Implement Document Detection Feature
Filestack enables users to detect their document in the image, transform it to fully fit the image, and preprocess it, such as de-noising and distortion reduction, in order to increase the accuracy of the OCR engine in text extraction. This feature is available now as part of the latest PHP SDK version, enhancing users’ document processing workflows.
Support for uploading files to S3 prefixes and subfolders
When storing a file using the FilestackClient class, the files are uploaded to the root of the S3 bucket. With the latest PHP SDK version, you can specify a directory path within your S3 bucket when using the upload function. This allows you to organize and manage your files more effectively within the S3 bucket. Here’s an example:
$client = new FilestackClient('YOUR_API_KEY');
$extras = [
'Filename' => 'somefilename.jpg',
];
$filepath = 'directory/within/bucket';
$filelink = $client->upload($filepath);
In this example, the file will be uploaded to the 'directory/within/bucket'
path within the S3 bucket, instead of the root directory.
Powerful File Conversion with Detailed Information
The Filestack PHP SDK provides a reliable way to convert various file types. To convert an already uploaded file to another file type, follow these steps:
- Create a new
Filelink
object by initializing it with the file handle and your API key. - Use the
convertFile
method to convert the file to the desired file type. The first parameter specifies the new file type:
use Filestack\filelink;
$filelink = new Filelink('some-file-handle', 'YOUR_API_KEY');
$filelink->convertFile('jpg');
The above code will convert the fetched file to a JPG file.
The convertFile
method also accepts a second parameter for conversion options. One of these options is docinfo
, which, if set to true
, will return more information about the converted file, such as the number of pages and the dimensions of the file:
use Filestack\filelink;
$filelink = new Filelink('some-file-handle', 'YOUR_API_KEY');
$filelink->convertFile('pdf', ['docinfo' => TRUE]);
The ability to retrieve additional information about the converted file can be particularly useful for developers who need to process or analyze the converted content further, enhancing the overall functionality and flexibility of the SDK.
Improved Type-hints
The PHP SDK provides type hints for some of its methods. These type-hints are now compatible with PHP 7 and later versions. For example, the convertFile
method in FilestackClient
specifies a return type-hint of \Filestack\Filelink
.
This improvement ensures compatibility with PHP 7 and later projects, allowing users to leverage modern PHP features effectively. This leads to easier integration and enhanced usability for users.
Improved File Uploads
The latest PHP SDK also includes improvements to the file upload process, providing developers with more control and flexibility. These enhancements help to ensure a more reliable and efficient file upload experience for PHP applications. For instance, the SDK has resolved the following issues that users faced in earlier versions:
- “Errored uploading to s3503.” error
- “file_not_found_exception” error when uploading files from a URL
- Error message indicating a call to the undefined function GuzzleHttp\Promise\settle()
These improvements help to streamline the file upload process and provide a more seamless experience for PHP developers.
Resolve Inability to Upload Files from URL using an absolute path
Previously, the SDK would return a “file_not_found_exception” error when attempting to upload files from a URL using an absolute path, despite the file being accessible at the provided URL. With the latest update, the Filestack team has resolved this issue, enabling developers to seamlessly upload files from URLs using the PHP SDK. This fix enhances the overall file management capabilities of the SDK, providing users with a more reliable and versatile solution for their application needs. Developers can now leverage the improved URL-based file upload functionality to streamline their workflows and deliver a better experience for their end-users, without the disruptions caused by the previous limitation.
Resolve Undefined Function Error in GuzzleHttp\Promise
The PHP SDK version 1.1.11 encountered problems with Guzzle promises, resulting in an error message indicating a call to the undefined function GuzzleHttp\Promise\settle()
. This issue significantly impacted the functionality of the Filestack PHP SDK, as it prevented users from successfully uploading files. The Filestack team has now resolved this problem, ensuring that developers can seamlessly perform file uploads using the latest version of the SDK. This fix enhances the overall stability and usability of the Filestack PHP integration, allowing users to confidently leverage the SDK’s file management capabilities without encountering disruptive errors. With this improvement, developers can now focus on building their applications without the need to seek workarounds or alternative solutions, leading to a more efficient and streamlined development process.
Improved Downloads
Storing and downloading files is easily handled using the FilestackClient
class.
try{
$client = new FilestackClient('YOUR_API_KEY');
$extras = [
'Location' => 'dropbox',
'Filename' => 'somefilename.jpg',
];
$filepath = '/path/to/file';
$filelink = $client->upload($filepath);
# download a file
$result = $client->download($filelink->handle, $filepath);
}
catch (FilstackException $e){
echo $e->getMessage();
echo $e->getCode();
}
The latest PHP SDK release has resolved the “bad request” error that users previously encountered when attempting to execute the download operation. Users can now successfully retrieve files from Filestack without disruptions to their workflows and application functionalities.
Python SDK updates
The Filestack Python SDK provides developers with many classes to interact with the Filestack API, the main two are:
- Client – for new file uploads.
- Filelink – for handling already uploaded files.
With the latest update, you can use these classes in your Python 3.12+ projects to build feature-rich web and mobile applications that efficiently manage and process files.
The latest version of the Python SDK also includes updates to the SDK dependencies, resolving the issue causing failed uploads while using Security Policy and App Secret, and support for new recent transformation API changes. Developers can now take advantage of new features and enhancements to improve their file management workflows.
Support New Recent Transformation API
The Python SDK now supports the following transformation tasks:
doc_to_images
smart_crop
pdfcreate
animate-images-to-gif
portrait enhance
- remove
beautify
andbeautify_plus
.
Moreover, add the following parameters:
- Add
metadata
parameter topdfconvert
task. - Add
file
parameter to thefallback
task.
By supporting these transformation tasks and parameters, the Python SDK provides developers with expanded capabilities to process and manipulate files within their applications via its API, enabling advanced functions such as converting documents to images, creating PDFs, and enhancing images. These changes allow developers to make more feature-rich and flexible apps that can handle a wider range of file types and transformations, giving their users a better and more seamless file management experience.
Conclusion
The latest versions of the Filestack offer enhanced functionality, stability, and compatibility with the latest PHP and Python programming language versions. Developers can now leverage the improved performance and bug fixes to enhance their applications. This upgrade ensures seamless integration and reliable file management capabilities within their projects. The Filestack team is committed to providing developers with the best possible experience and will continue to enhance the SDKs based on user feedback and evolving requirements.
Senior web developer with a profound knowledge of the Javascript and PHP ecosystem. Familiar with several JS tools, frameworks, and libraries. Experienced in developing interactive websites and applications.
Read More →