Xenforo 2.1 how to set a CDN servers to store uploaded attachments

godayhu

New member
Registered
Joined
Dec 29, 2019
Messages
3
Points
3

Reputation:

Due to the slow download speed of the server, I want to set up a CDN website to store uploaded attachments, such as http://cdn.example.com/

In official documentation:
https://xenforo.com/xf2-docs/manual/config/#data-and-script-locations

The configuration about this is in the Config.php file

$ config ['externalDataPath'] = 'data';
$ config ['externalDataUrl'] = 'http://cdn.example.com/data';
$ config ['internalDataPath'] = 'internal_data';
$ config ['internalDataUrl'] = 'http://cdn.example.com/internal_data';

After setup, the website will not work, and the avatar and attachments cannot be uploaded and read.
what should I do? Is it safe?
 

kiniemxua

Nhất Túy Tiêu Dao
Collaborate
Registered
Joined
Jun 30, 2019
Messages
83
Points
243

Reputation:

Only member can download and see attachment! :LOL:
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
194
Points
53

Reputation:

It's a good way to make our site faster and I have used it for a long time, but I am facing a problem when I am trying to upload a new media in media library, it is not recognized the new path of CDN or remote server.
Could someone can help to fix this issue, please.
Best Regards,
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
194
Points
53

Reputation:

Dear, I mean, when you are using addon like ([bd] Attachment Store 2.1.1) to change the folder of attachments of your forums from localhost to remote server or any other clouds server, it will work normally in your threads and posts, but in the media library, you should change some code on it files to host the attached media on that server or cloud storage when you are uploading any mp3 or video in your media library.
Thank you.
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
194
Points
53

Reputation:

@kiniemxua It's needed in my forum dear, this is the error which I get when I am uploading any mp3 or video file in Media library:
HTML:
League\Flysystem\FileExistsException: File already exists at path: 2020/02/32291_qal_gani_byd_iumin.mp3 in src/vendor/league/flysystem/src/Filesystem.php at line 405
League\Flysystem\Filesystem->assertAbsent() in src/vendor/league/flysystem/src/Filesystem.php at line 211
League\Flysystem\Filesystem->rename()
call_user_func_array() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 431
League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 395
League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall() in src/addons/Xfrocks/AttachmentStore/Fs.php at line 41
Xfrocks\AttachmentStore\Fs->delegateMethodCall() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 303
League\Flysystem\EventableFilesystem\EventableFilesystem->rename() in src/vendor/league/flysystem/src/MountManager.php at line 240
League\Flysystem\MountManager->move() in src/addons/XFMG/Attachment/Media.php at line 217
XFMG\Attachment\Media->onAssociation() in src/addons/XFMG/Service/Media/Creator.php at line 258
XFMG\Service\Media\Creator->_save() in src/addons/DBTech/Credits/XFMG/Service/Media/Creator.php at line 54
DBTech\Credits\XFMG\Service\Media\Creator->_save() in src/XF/Service/ValidateAndSavableTrait.php at line 40
XFMG\Service\Media\Creator->save() in src/addons/XFMG/Pub/Controller/Media.php at line 771
XFMG\Pub\Controller\Media->actionSaveMedia() in src/XF/Mvc/Dispatcher.php at line 350
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 261
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2184
XF\App->run() in src/XF.php at line 391
XF::runApp() in index.php at line 20

Only photos library are working,
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
194
Points
53

Reputation:

@kiniemxua no dear, this error is shown with any file, no previous file had the same name before.
 

kiniemxua

Nhất Túy Tiêu Dao
Collaborate
Registered
Joined
Jun 30, 2019
Messages
83
Points
243

Reputation:

@shababalrafedain i have installed Bd Attachment Store and have the same error, but i have been choose: Delayed Processing and no error found. Wating and look my forum how it work
 

Wolf Knight

+Lifetime VIP+
+Lifetime VIP+
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Jul 3, 2019
Messages
194
Points
53

Reputation:

@kiniemxua I did it now and tried but it gave the same error :(
Code:
League\Flysystem\FileExistsException: File already exists at path: 2020/02/32332_aghani_tamr_xhsni.mp3 in src/vendor/league/flysystem/src/Filesystem.php at line 405
League\Flysystem\Filesystem->assertAbsent() in src/vendor/league/flysystem/src/Filesystem.php at line 211
League\Flysystem\Filesystem->rename()
call_user_func_array() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 431
League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 395
League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall() in src/addons/Xfrocks/AttachmentStore/Fs.php at line 41
Xfrocks\AttachmentStore\Fs->delegateMethodCall() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 303
League\Flysystem\EventableFilesystem\EventableFilesystem->rename() in src/vendor/league/flysystem/src/MountManager.php at line 240
League\Flysystem\MountManager->move() in src/addons/XFMG/Attachment/Media.php at line 217
XFMG\Attachment\Media->onAssociation() in src/addons/XFMG/Service/Media/Creator.php at line 258
XFMG\Service\Media\Creator->_save() in src/addons/DBTech/Credits/XFMG/Service/Media/Creator.php at line 54
DBTech\Credits\XFMG\Service\Media\Creator->_save() in src/XF/Service/ValidateAndSavableTrait.php at line 40
XFMG\Service\Media\Creator->save() in src/addons/XFMG/Pub/Controller/Media.php at line 771
XFMG\Pub\Controller\Media->actionSaveMedia() in src/XF/Mvc/Dispatcher.php at line 350
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 261
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2184
XF\App->run() in src/XF.php at line 391
XF::runApp() in index.php at line 20
 

kiniemxua

Nhất Túy Tiêu Dao
Collaborate
Registered
Joined
Jun 30, 2019
Messages
83
Points
243

Reputation:

@shababalrafedain it s error because the BD store mod, can't not delete the local file after upload via cdn or ftp server. ?

Bd Store make i lost some file, i should reupload again to my forum. I will test again on a fresh forum. ?
 

zeus1971

Collaborate
Collaborate
Registered
Joined
Apr 18, 2020
Messages
310
Points
73

Reputation:

CDN for XF, for attachments or media, can't be used. Only Avatars and thumbnails....works.
So, a no sense to use CDN to not be able to cache thousends of pictures...
 
Last edited:
Top