Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Uploading using url through the API seems broken #130

Closed
leonluc-dev opened this issue Dec 1, 2021 · 2 comments
Closed

Uploading using url through the API seems broken #130

leonluc-dev opened this issue Dec 1, 2021 · 2 comments

Comments

@leonluc-dev
Copy link

leonluc-dev commented Dec 1, 2021

When using the api to upload an image like this https://myserver.com/api/1/upload?key=api-key&format=json&source=https%3A%2F%2Fexample.com%2image.jpg the api cannot process the image.

This seems related to this particular bit of code:

case G\is_image_url($source) || G\is_url($source):
$sourceQs = G\getQsParams()['source'];
$source = isset($sourceQs) ? $sourceQs : $source;

At line 61 the $source variable is already plaintext (url decoded). However, the G\getQsParams()['source']; returns an url encoded value and sets the source variable to it.
This is causing the CHV\Image::uploadToWebsite($source); call to return "invalid file type" (since it cannot handle url encoded values)

@rodber
Copy link
Owner

rodber commented Dec 3, 2021

Try using POST.

@leonluc-dev
Copy link
Author

POST using a x-www-form-urlencoded body with the same params does work. Thanks for the tip!

I wasn't aware POST was required due to the docs mentioning support for GET

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

No branches or pull requests

2 participants