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
>>  
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FHttpClients%2FFacebookCurlHttpClient.php&line=150>
>>  
>> Stack trace: #0 /base/data/home/apps/s~ 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FFacebookRequest.php&line=260>
>> My-App-ID 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FHttpClients%2FFacebookCurlHttpClient.php&line=150>
>> /1.385481947954511984/fb/src/Facebook/FacebookRequest.php(260) 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FFacebookRequest.php&line=260>
>> : Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 
>> 'POST', Array)
>> #1 /base/data/home/apps/s~ 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Fpost.php&line=188>
>> My-App-ID 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FHttpClients%2FFacebookCurlHttpClient.php&line=150>
>> /1.385481947954511984/post.php(188) 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Fpost.php&line=188>
>> : Facebook\FacebookRequest->execute()
>> #2 {main} thrown in /base/data/home/apps/s~ 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FHttpClients%2FFacebookCurlHttpClient.php&line=150>
>> My-App-ID 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FHttpClients%2FFacebookCurlHttpClient.php&line=150>/1.385481947954511984/fb/src/Facebook/HttpClients/FacebookCurlHttpClient.php
>>  
>> on line 150 
>> <https://console.developers.google.com/project/richerposts/clouddev/source/resolve_location?appModule=default&appVersion=1&timestampNanos=1436032217899000000&file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~richerposts%2F1.385481947954511984%2Ffb%2Fsrc%2FFacebook%2FHttpClients%2FFacebookCurlHttpClient.php&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://groups.google.com/d/msgid/google-appengine/73af3fec-d5dc-4437-a973-09a46fba037c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to