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

Guzzle Error on Upload #51

Closed
mytuny opened this issue Mar 11, 2023 · 6 comments
Closed

Guzzle Error on Upload #51

mytuny opened this issue Mar 11, 2023 · 6 comments

Comments

@mytuny
Copy link

mytuny commented Mar 11, 2023

I'm trying to use the PHP SDK to upload a file but keep getting the same error despite using the basic examples ever (as explained in documentations for instance).

The error says: "Status code must be an integer value between 1xx and 5xx."

Which, as far as I can tell, is an issue related to the Guzzle package since I also found people in their community claiming to have the same error using Guzzle in their own contexts as well.

I believe a patch to the Guzzle package is required to solve the problem!

PS: I'm under Windows 10 / PHP 7.4

Thanks

@imagekitio
Copy link
Contributor

Which version of PHP SDK are you using?

@mytuny
Copy link
Author

mytuny commented Mar 12, 2023

Since I used the default composer installation command, I got the version 3.0.0 (the latest version on Packagist).

@msheheryar1
Copy link
Contributor

@mytuny can you please share the code you are trying with?

@mytuny
Copy link
Author

mytuny commented Mar 17, 2023

<?php

use ImageKit\ImageKit;

require __DIR__ . '/../vendor/autoload.php';

$img = file_get_contents(__DIR__."/image.jpg");
$base64Img = base64_encode($img);

$imageKit = new ImageKit(
    'public_xxxxxxx',
    'private_xxxxxxx',
    'https://ik.imagekit.io/xxxxxxx'
);

$uploadFile = $imageKit->uploadFile([
    'file' => $base64Img,
    'fileName' => 'image-test.jpg'
]);

echo ("Upload base64" . json_encode($uploadFile));

This is only one variation out of many I tried with.

@imagekitio
Copy link
Contributor

Fixed in version 3.0.3

@koolio29
Copy link

koolio29 commented Oct 5, 2023

Hiya, I am currently using V3.0.3 with PHP 8.1.1 on windows 11. However, this error is still persisting. Followed the suggested solution here but it didn't work.

// Simplified version of what I am working with
$client = new ImageKit($publicKey, $privateKey, $endpoint);
$response = $client->uploadFile([
    'file' => $base64Image,
    'fileName' => $fileName,
    'folder' => $folder,
]);

var_dump($response);

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

No branches or pull requests

4 participants