adobe / adobe/stock-api-libphp

A search with SimilarImage raises an exception

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
20
Forks
23
PR merge metrics
No merged PRs in 30d

Description

# 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)) { ... }`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.