[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-05 Thread Stuart Langley
Files that you write to vfs are removed at the end of the request. If you 
need the files to persist between requests you'll need to write or move the 
files from vfs to gs.

On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:
>
> Hi,
>
> I've got my main PHP script writing an image file out to vfs:// using the 
> PHP GD lib function imagepng(image, filename)
>
> Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses Curl 
> internally to read the file, so I simply supply the vfs:// filename to it. 
> I then get back an error saying it can't open the file:
>
> PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' with 
> message 'couldn't open file "vfs://root/temp/T199952197c"' in 
> /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
>  
> 
>  
> Stack trace: #0 /base/data/home/apps/s~ 
> 
> My-App-ID 
> 
> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
> 
> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
> 'POST', Array)
> #1 /base/data/home/apps/s~ 
> 
> My-App-ID 
> 
> /1.385481947954511984/post.php(188) 
> 
> : Facebook\FacebookRequest->execute()
> #2 {main} thrown in /base/data/home/apps/s~ 
> 
> My-App-ID 
> /1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php
>  
> on line 150 
> 
>
> My first thought was a permissions issue (i.e. FB script not allowed to 
> read file my script created), but checking permissions of my image file in 
> vfs:// - they are set to 0666 and I've tried changing them to both 0644 and 
> 0777 (and confirming they are set) and still get the error...
>
> Any ideas please?
>
> Many thanks!
> Alex
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://gr

[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-06 Thread Alex Kerr
Thanks Stuart. However, I've looked into this and confirmed that's not the 
problem. At the point the exception is thrown in the FB SDK (this is after 
CURL has tried to post and returned an error), I added some code in to 
check the temp file to be posted still exists and can be read (by 
file_get_contents) and both are true - the file is fine and readable, and 
permissions are set to 0777 (not sure if necessary or not, but just in 
case). So the problem is CURL cannot read the file from vfs:// - is this a 
bug?

I also checked what parameters were being passed to CURL immediately before 
it executes, and they are as follows (I hardcoded the filename):
Parameters = Array ( [source] => CURLFile Object ( [name] => 
vfs://root/temp/mytest0001 [mime] => image/png [postname] => ) [message] => 
[access_token] => My-Token [appsecret_proof] => My-Secret-Proof )

I am generating the temp file's name only once in the code, using: 

$randfname = 'mytest0001'; // Normally a short random string $imfname = 
sys_get_temp_dir().'/'.$randfname;

As a side note, it didn't make sense that the vfs:// file would be deleted 
at the point CURL accesses it, because the FB SDK is called to do the post 
immediately after the file is created, and I assume the call is not 
asynchronous, so my script must be waiting for that to return and thus not 
deleting any temp files (confirmed of course, as above).

Any ideas appreciated!

Many thanks,
Alex

On Sunday, July 5, 2015 at 4:23:35 PM UTC+1, Stuart Langley wrote:
>
> Files that you write to vfs are removed at the end of the request. If you 
> need the files to persist between requests you'll need to write or move the 
> files from vfs to gs.
>
> On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:
>>
>> Hi,
>>
>> I've got my main PHP script writing an image file out to vfs:// using the 
>> PHP GD lib function imagepng(image, filename)
>>
>> Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses 
>> Curl internally to read the file, so I simply supply the vfs:// filename to 
>> it. I then get back an error saying it can't open the file:
>>
>> PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' with 
>> message 'couldn't open file "vfs://root/temp/T199952197c"' in 
>> /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
>>  
>> 
>>  
>> Stack trace: #0 /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> 
>> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
>> 
>> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
>> 'POST', Array)
>> #1 /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> 
>> /1.385481947954511984/post.php(188) 
>> 
>> : Facebook\FacebookRequest->execute()
>> #2 {main} thrown in /base/data/home/apps/s~ 
>> 

[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-06 Thread Alex Kerr
Also further to my last reply, tried this all with GCS (accessed via gs:// 
URL) and it doesn't work either, exactly the same error from CURL. I also 
tried changing the 'source' field in the CURLFile request to 'url' but that 
was the same again.

Looks like curl can't read from either vfs or gcs?

I do have curl.so enabled in my php.ini and curl_lite not enabled.

Many thanks, for any help,
Alex

On Sunday, July 5, 2015 at 4:23:35 PM UTC+1, Stuart Langley wrote:
>
> Files that you write to vfs are removed at the end of the request. If you 
> need the files to persist between requests you'll need to write or move the 
> files from vfs to gs.
>
> On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:
>>
>> Hi,
>>
>> I've got my main PHP script writing an image file out to vfs:// using the 
>> PHP GD lib function imagepng(image, filename)
>>
>> Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses 
>> Curl internally to read the file, so I simply supply the vfs:// filename to 
>> it. I then get back an error saying it can't open the file:
>>
>> PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' with 
>> message 'couldn't open file "vfs://root/temp/T199952197c"' in 
>> /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
>>  
>> 
>>  
>> Stack trace: #0 /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> 
>> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
>> 
>> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
>> 'POST', Array)
>> #1 /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> 
>> /1.385481947954511984/post.php(188) 
>> 
>> : Facebook\FacebookRequest->execute()
>> #2 {main} thrown in /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> /1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php
>>  
>> on line 150 
>> 
>>
>> My first thought was a permissions issue (i.e. FB script not allowed to 
>> read file my script created), but checking permissions of my image file in 
>> vfs:// - they are set to 0666 and I've tried changing them to both 0644 and 
>> 0777 (and confirmi

[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-06 Thread Alex Kerr
Sorry for a 3rd reply, but just to confirm my code all works fine when the 
image to be uploaded is a static file uploaded with my app, including if 
the image is in a subfolder. So it appears curl only has a problem with 
files on vfs:// or gfs:// (unfortunately this is critical to my app as I 
need somewhere to store temp files momentarily...)

Thanks

On Sunday, July 5, 2015 at 4:23:35 PM UTC+1, Stuart Langley wrote:
>
> Files that you write to vfs are removed at the end of the request. If you 
> need the files to persist between requests you'll need to write or move the 
> files from vfs to gs.
>
> On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:
>>
>> Hi,
>>
>> I've got my main PHP script writing an image file out to vfs:// using the 
>> PHP GD lib function imagepng(image, filename)
>>
>> Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses 
>> Curl internally to read the file, so I simply supply the vfs:// filename to 
>> it. I then get back an error saying it can't open the file:
>>
>> PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' with 
>> message 'couldn't open file "vfs://root/temp/T199952197c"' in 
>> /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
>>  
>> 
>>  
>> Stack trace: #0 /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> 
>> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
>> 
>> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
>> 'POST', Array)
>> #1 /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> 
>> /1.385481947954511984/post.php(188) 
>> 
>> : Facebook\FacebookRequest->execute()
>> #2 {main} thrown in /base/data/home/apps/s~ 
>> 
>> My-App-ID 
>> /1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php
>>  
>> on line 150 
>> 
>>
>> My first thought was a permissions issue (i.e. FB script not allowed to 
>> read file my script created), but checking permissions of my image file in 
>> vfs:// - they are set to 0666 and I've tried changing them to both 0644 and 
>> 0777 (and confirming they are set) and still get the error...
>

[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-06 Thread Stuart Langley
Hi Alex,

I don't think cURL will read a file from a user stream wrapper - so you're 
kind of stuck.

Can you create the multipart form manually?

On Tuesday, 7 July 2015 03:39:43 UTC+10, Alex Kerr wrote:
>
> Sorry for a 3rd reply, but just to confirm my code all works fine when the 
> image to be uploaded is a static file uploaded with my app, including if 
> the image is in a subfolder. So it appears curl only has a problem with 
> files on vfs:// or gfs:// (unfortunately this is critical to my app as I 
> need somewhere to store temp files momentarily...)
>
> Thanks
>
> On Sunday, July 5, 2015 at 4:23:35 PM UTC+1, Stuart Langley wrote:
>>
>> Files that you write to vfs are removed at the end of the request. If you 
>> need the files to persist between requests you'll need to write or move the 
>> files from vfs to gs.
>>
>> On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:
>>>
>>> Hi,
>>>
>>> I've got my main PHP script writing an image file out to vfs:// using 
>>> the PHP GD lib function imagepng(image, filename)
>>>
>>> Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses 
>>> Curl internally to read the file, so I simply supply the vfs:// filename to 
>>> it. I then get back an error saying it can't open the file:
>>>
>>> PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' with 
>>> message 'couldn't open file "vfs://root/temp/T199952197c"' in 
>>> /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
>>>  
>>> 
>>>  
>>> Stack trace: #0 /base/data/home/apps/s~ 
>>> 
>>> My-App-ID 
>>> 
>>> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
>>> 
>>> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
>>> 'POST', Array)
>>> #1 /base/data/home/apps/s~ 
>>> 
>>> My-App-ID 
>>> 
>>> /1.385481947954511984/post.php(188) 
>>> 
>>> : Facebook\FacebookRequest->execute()
>>> #2 {main} thrown in /base/data/home/apps/s~ 
>>> 
>>> My-App-ID 
>>> /1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php
>>>  
>>> on line 150 
>>> 
>>>
>>> My first thought was a permis

[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-07 Thread Alex Kerr
Thanks Stuart - OK, just trying to understand this - so the user stream 
wrapper that Google have implemented is what gives the gs:// or vfs:// 
access?

So if I create the multipart form manually I could get around that - can 
you give any tips or pointers how I'd get started with doing that please, 
not quite sure where to start!

Many thanks,
Alex

On Tuesday, July 7, 2015 at 2:39:04 AM UTC+1, Stuart Langley wrote:
>
> Hi Alex,
>
> I don't think cURL will read a file from a user stream wrapper - so you're 
> kind of stuck.
>
> Can you create the multipart form manually?
>
> On Tuesday, 7 July 2015 03:39:43 UTC+10, Alex Kerr wrote:
>>
>> Sorry for a 3rd reply, but just to confirm my code all works fine when 
>> the image to be uploaded is a static file uploaded with my app, including 
>> if the image is in a subfolder. So it appears curl only has a problem with 
>> files on vfs:// or gfs:// (unfortunately this is critical to my app as I 
>> need somewhere to store temp files momentarily...)
>>
>> Thanks
>>
>> On Sunday, July 5, 2015 at 4:23:35 PM UTC+1, Stuart Langley wrote:
>>>
>>> Files that you write to vfs are removed at the end of the request. If 
>>> you need the files to persist between requests you'll need to write or move 
>>> the files from vfs to gs.
>>>
>>> On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:

 Hi,

 I've got my main PHP script writing an image file out to vfs:// using 
 the PHP GD lib function imagepng(image, filename)

 Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses 
 Curl internally to read the file, so I simply supply the vfs:// filename 
 to 
 it. I then get back an error saying it can't open the file:

 PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' 
 with message 'couldn't open file "vfs://root/temp/T199952197c"' in 
 /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
  
 
  
 Stack trace: #0 /base/data/home/apps/s~ 
 
 My-App-ID 
 
 /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
 
 : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
 'POST', Array)
 #1 /base/data/home/apps/s~ 
 
 My-App-ID 
 
 /1.385481947954511984/post.php(188) 
 
 : Facebook\FacebookRequest->execute()
 #2 {main} thrown in /base/data/home/apps/s~ 
 
 My-App-ID 
 

[google-appengine] Re: PHP script can't read file from vfs:// (in memory file system) created by my other PHP script

2015-07-09 Thread Stuart Langley
Hey Alex,

I'm on vacation, I'll try and work out some sample code for you when I get 
back.

Cheers

On Tuesday, 7 July 2015 20:42:38 UTC+10, Alex Kerr wrote:
>
> Thanks Stuart - OK, just trying to understand this - so the user stream 
> wrapper that Google have implemented is what gives the gs:// or vfs:// 
> access?
>
> So if I create the multipart form manually I could get around that - can 
> you give any tips or pointers how I'd get started with doing that please, 
> not quite sure where to start!
>
> Many thanks,
> Alex
>
> On Tuesday, July 7, 2015 at 2:39:04 AM UTC+1, Stuart Langley wrote:
>>
>> Hi Alex,
>>
>> I don't think cURL will read a file from a user stream wrapper - so 
>> you're kind of stuck.
>>
>> Can you create the multipart form manually?
>>
>> On Tuesday, 7 July 2015 03:39:43 UTC+10, Alex Kerr wrote:
>>>
>>> Sorry for a 3rd reply, but just to confirm my code all works fine when 
>>> the image to be uploaded is a static file uploaded with my app, including 
>>> if the image is in a subfolder. So it appears curl only has a problem with 
>>> files on vfs:// or gfs:// (unfortunately this is critical to my app as I 
>>> need somewhere to store temp files momentarily...)
>>>
>>> Thanks
>>>
>>> On Sunday, July 5, 2015 at 4:23:35 PM UTC+1, Stuart Langley wrote:

 Files that you write to vfs are removed at the end of the request. If 
 you need the files to persist between requests you'll need to write or 
 move 
 the files from vfs to gs.

 On Sunday, 5 July 2015 04:04:11 UTC+10, Alex Kerr wrote:
>
> Hi,
>
> I've got my main PHP script writing an image file out to vfs:// using 
> the PHP GD lib function imagepng(image, filename)
>
> Then I'm using Facebook's PHP SDK to try and post that. FB's SDK uses 
> Curl internally to read the file, so I simply supply the vfs:// filename 
> to 
> it. I then get back an error saying it can't open the file:
>
> PHP Fatal error: Uncaught exception 'Facebook\FacebookSDKException' 
> with message 'couldn't open file "vfs://root/temp/T199952197c"' in 
> /base/data/home/apps/s~My-App-ID/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php:150
>  
> 
>  
> Stack trace: #0 /base/data/home/apps/s~ 
> 
> My-App-ID 
> 
> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
> 
> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
> 'POST', Array)
> #1 /base/data/home/apps/s~ 
> 
> My-App-ID 
> 
> /1.385481947954511984/post.php(188) 
> 
> : Facebook\FacebookRequest->execute()
> #2 {main} thrown in /base/data/home/apps/s~ 
> 
> My-App-ID