Hi,

I am using Simple Oauth2 module for user authentication and setting Bearer token (access_token which received from simple_oauth2 service) in Authorization header for every requests. When I post a file from POSTMAN REST client, I am getting the following error.

[client 127.0.0.1:45600] Uncaught PHP Exception RuntimeException: "SplFileInfo::getSize(): stat failed for /tmp/php3qDWbF" at /path/to/php-file,php

Tried a small file with size just 9.5 KB only, but still I am getting the same error. I also tried the following experiment based on the post found in stackoverflow. But it didn't work for me.

- post_max_size must be larger than upload_max_filesize
- memory_limit should be larger than post_max_size

Any thoughts ?

Thanks,

Comments

anoopmohan created an issue. See original summary.

anoopmohan’s picture

Issue summary: View changes
anoopmohan’s picture

Status: Needs review » Needs work
e0ipso’s picture

Any suspicion why this is this module's bug?

anoopmohan’s picture

It works correctly if we have done cookie based authentication. When we use the bearer token for the same API, it fails.

e0ipso’s picture

I'm not able to reproduce this locally. Any other tips that can help someone to fix this issue?

slivorezka’s picture

I got the same bug.

e0ipso, to reproduce this locally try it:

<?php
// In a some callback method.
$picture = \Drupal::request()->files->get('picture');
var_dump($picture->getSize());
// Or
var_dump(is_uploaded_file($picture->getRealPath()));
?>

And try do a request to this callback method via Postman or any other code.

If I use Bearer token authentication I get this PHP error:

RuntimeException: SplFileInfo::getSize(): stat failed for /tmp/php4dhg5s ...

But if I use cookie based authentication all Ok.
Also, for anonymous users all Ok too.

e0ipso’s picture

Have you tried https://www.drupal.org/project/jsonapi_file or https://www.drupal.org/project/drupal/issues/1927648?page=1#comment-1246...? Those could contain good tips.

Please post back any findings!

e0ipso’s picture

Status: Needs work » Closed (works as designed)

Closing for now. Please reopen if necessary.

e0ipso’s picture

Status: Closed (works as designed) » Closed (duplicate)
Related issues: +#2934491: Creating a validateAuthenticatedRequest moves & renames any temporary files