XF 2.1 BackBlaze adapter error

OkanOzturk

Active member
I was working on Backblaze integration, but when I try to upload files I get the error below.

BackBlaze api: https://github.com/RunCloudIO/flysystem-b2

Code:
$config['fsAdapters']['data'] = function()
{
    return new \RunCloudIO\FlysystemB2\BackblazeAdapter('xx', 'xx', 'xx');
};

Code:
ErrorException: [E_WARNING] fclose(): supplied resource is not a valid stream resource src\XF\Util\File.php:186

#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] fcl...', 'C:\\xampp\\htdocs...', 186, Array)
#1 src\XF\Util\File.php(186): fclose(Resource id #139)
#2 src\XF\Service\Attachment\Preparer.php(86): XF\Util\File::copyFileToAbstractedPath('C:\\xampp\\htdocs...', 'data://attachme...')
#3 src\XF\Service\Attachment\Preparer.php(23): XF\Service\Attachment\Preparer->insertDataFromFile(Object(XF\FileWrapper), 1, Array)
#4 src\XF\Attachment\Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(XF\Attachment\Post), Object(XF\FileWrapper), Object(XF\Entity\User), 'xx...')
#5 src\XF\Pub\Controller\Attachment.php(89): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#6 src\XF\Mvc\Dispatcher.php(350): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#7 src\XF\Mvc\Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\Attachment), NULL)
#8 src\XF\Mvc\Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\Attachment), NULL)
#9 src\XF\Mvc\Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src\XF\App.php(2184): XF\Mvc\Dispatcher->run()
#11 src\XF.php(391): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}
 
Last edited:
I tried different api but same error :(

Api: https://github.com/gliterd/flysystem-backblaze

Code:
$config['fsAdapters']['data'] = function()
{
    $client = new \BackblazeB2\Client('xx', 'xx');
    return new \Mhetreramesh\Flysystem\BackblazeAdapter($client, 'xx');
};


Code:
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] fcl...', 'C:\\xampp\\htdocs...', 186, Array)
#1 src\XF\Util\File.php(186): fclose(Resource id #152)
#2 src\XF\Service\Attachment\Preparer.php(86): XF\Util\File::copyFileToAbstractedPath('C:\\xampp\\htdocs...', 'data://attachme...')
#3 src\XF\Service\Attachment\Preparer.php(23): XF\Service\Attachment\Preparer->insertDataFromFile(Object(XF\FileWrapper), 1, Array)
#4 src\XF\Attachment\Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(XF\Attachment\Post), Object(XF\FileWrapper), Object(XF\Entity\User), '1997caff1ee04cc...')
#5 src\XF\Pub\Controller\Attachment.php(89): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#6 src\XF\Mvc\Dispatcher.php(350): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#7 src\XF\Mvc\Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\Attachment), NULL)
#8 src\XF\Mvc\Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\Attachment), NULL)
#9 src\XF\Mvc\Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src\XF\App.php(2184): XF\Mvc\Dispatcher->run()
#11 src\XF.php(391): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}
 
And the error persists if you use a stock configuration or try uploading a different file? A bit curious as the fclose() operation isn't dependent on the adapter as far as I can tell. You're passing it a resource from two lines above it, which I believe should be a local temporary file.
 
When I put @ at the beginning of fclose on line src\XF\Util\File.php:186 I am not getting an error and backblaze cloud is working perfectly.
 
I used to have a working copy of a B2 adapter which required a tiny update to one of the core XenForo files. If you guys want it I can look it up this weekend and give it away for free. Remember that it requires a modification to the XenForo source code but other than that it was working fine.
 
Yeah, similar issue to what I suggested here:

 
Oh wow, a year ago. Hope it gets changed, Azure Blob Storage does an fclose inside the library as well. Not super practical to keep making core file edits, and I'd like to avoid editing the library files as well
 
 
nice. hopefully someone would write a guide on what needs to be done to get b2 working. i barely managed to get s3 working following the official guide (had to make bucket public to get it to work). would love to switch to b2 in the future. cheers.
 
was wondering if the latest stable update of xenforo now support b2 without any modification? has someone written a guide highlighting changes to be made from the S3 guide provided by xenforo developers. thanks!
 
Top Bottom