Project

General

Profile

Actions

Feature #65040

closed

Use "is_default" flag from File Stoarge for drag&drop FAL uploads

Added by Viktor Livakivskyi almost 10 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2015-02-12
Due date:
% Done:

100%

Estimated time:
PHP Version:
5.5
Tags:
Complexity:
Sprint Focus:

Description

Drag&drop functinality for FAL uploads works really nice, but it lacks possibility to configure default upload storage.
Yes, there is a options.defaultUploadFolder under User TSconfig, but I don't want to configure it for every admin user and each BE usergroup.
Therefore it would be nice to use an existing "Is default storage?" checkbox for this purpose in case, when options.defaultUploadFolder is empty for a BE user. And only if no storages are found with "is_default" set, the first available should be taken.

Alternative solution: make File Storages sortable in BE.

Current solution, which I'm using on production: "General Storage" is renamed to "1st General Storage" to appear first in list and this is very hacky.

Actions #1

Updated by Viktor Livakivskyi almost 10 years ago

Forgot to mention: this happens under TYPO3 6.2.9

Actions #2

Updated by Frans Saris over 9 years ago

So if I understand you request correctly you want in BackendUserAuthentication::getDefaultUploadFolder() to first check the default storage before looping through all available storages to find the default upload folder.

Something like:

    /**
     * Returns a \TYPO3\CMS\Core\Resource\Folder object that is used for uploading
     * files by default.
     * This is used for RTE and its magic images, as well as uploads
     * in the TCEforms fields, unless otherwise configured (will be added in the future)
     *
     * the default upload folder for a user is the defaultFolder on the first
     * filestorage/filemount that the user can access
     * however, you can set the users' upload folder like this:
     *
     * options.defaultUploadFolder = 3:myfolder/yourfolder/
     *
     * @return \TYPO3\CMS\Core\Resource\Folder|boolean The default upload folder for this user
     */
    public function getDefaultUploadFolder() {
        $uploadFolder = $this->getTSConfigVal('options.defaultUploadFolder');
        if ($uploadFolder) {
            $uploadFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($uploadFolder);
        } else {
            foreach($this->getFileStorages() as $storage) {
                if ($storage->isDefault()) {
                    try {
                        $uploadFolder = $storage->getDefaultFolder();
                        break;
                    } catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
                        // If the folder is not accessible (no permissions / does not exist) we skip this one.
                    }
                    break;
                }
            }
            if (!$uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
                /** @var ResourceStorage $storage */
                foreach ($this->getFileStorages() as $storage) {
                    try {
                        $uploadFolder = $storage->getDefaultFolder();
                        break;
                    } catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
                        // If the folder is not accessible (no permissions / does not exist) try the next one.
                    }
                }
            }
        }
        if ($uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
            return $uploadFolder;
        } else {
            return FALSE;
        }
    }
Actions #3

Updated by Viktor Livakivskyi over 9 years ago

Hi, Frans.

Yes, your posted code is the exact solution, I'd like to see in a core =)

Actions #4

Updated by Gerrit Code Review over 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37159

Actions #5

Updated by Gerrit Code Review over 9 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37401

Actions #6

Updated by Frans Saris over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF