Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A search with SimilarImage raises an exception #25

Open
joaquin-freepik opened this issue Aug 8, 2023 · 0 comments
Open

A search with SimilarImage raises an exception #25

joaquin-freepik opened this issue Aug 8, 2023 · 0 comments

Comments

@joaquin-freepik
Copy link

Issue report

Brief description of issue

Try to search with SimilarImage using code like:

    $search_params = new SearchParameters();
    $search_params->setSimilarImage(true);

    $request = new SearchFilesRequest();
    $request->setLocale('en-US');
    $request->setSearchParams($search_params);
    $request->setSimilarImage("myimage.jpg");

    $response = $client->searchFilesInitialize($request, $accessToken)->getNextResponse();

You will get a StockApi exception with the error message "Image File is not readable".

The exception is raised in HttpClient.php:92, where it checks if $file is a readable file. However, $file contains the binary content of the image file, not the image name. Just below this code, $file is used as the contents of a multipart upload (assuming it contains the content of the image). My guess is the if (!is_readable($file)) { ... } block is not needed and is introducing this bug.

Proposed fix (if applicable)

Remove the if (!is_readable($file)) { ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant