BobCasarini
BobCasarini

Octobercms ver. 2.0 My local and production environments are both connected to digital ocean spaces on the same bucket as file system for uploaded files and images. It's very strange: Locally everything works fine while in production the media manager very often responds with a 503 head-object slow down error. I think the problem could be a difference in the php configuration or something else but googling around I cannot find a solution. Thanks in advance for anyone who can help me

daftspunk
daftspunk

Hi BobCasarini,

This is unusual, suggest contacting Digital Ocean to find out why it happens, especially if it works normally on your localhost.

BobCasarini
BobCasarini

Thanks @daftpunk. The problem is due to an excess of requests per second made by the server to the digitalocean spaces service. I solved it modifying the medialibrary class forcing a delay in the request loop:

`

protected function scanFolderContents($fullFolderPath)
{
    $result = [
        'files' => [],
        'folders' => []
    ];

    $files = $this->getStorageDisk()->files($fullFolderPath);

    foreach ($files as $file) {
        if ($libraryItem = $this->initLibraryItem($file, MediaLibraryItem::TYPE_FILE)) {
            /**
             * Delay of a tenth of a second to solve the problem
             * 503 Slow down
             */
            usleep(100000);

            $result['files'][] = $libraryItem;
        }
    }

    $folders = $this->getStorageDisk()->directories($fullFolderPath);
    foreach ($folders as $folder) {
        if ($libraryItem = $this->initLibraryItem($folder, MediaLibraryItem::TYPE_FOLDER)) {
            $result['folders'][] = $libraryItem;
        }
    }

    return $result;
}

` and now it works fine. I know this is not a good practice and I'm trying a different solution creating a new custom driver called 'digitalocean' but at the moment I don't know how to register a custom driver for the filemanager and I cannot find any documentation about that

Last updated

daftspunk
daftspunk

Thanks for reporting back. We will likely fix this in the next iteration of the media manager. I have added this particular issue to our internal tracker.

1-4 of 4