Assets - uploading additional file types

Hello,

i would like to add file types to be uploaded using the asset action [omekas]/admin/asset

I saw the phtml file, that i edited to add the MIME i needed, but even though the MIME i want to use (application/pdf) is in the allowed extensions and all of my website, i can’t manage to ge the uploader to accept them.

I understood that the file application/src/Controller/Admin/AssetController.php handles this, but i am unfamiliar with laminas, and i found myself stuck

 public function addAction()
    {
        $httpResponse = $this->getResponse();
        $httpResponse->getHeaders()->addHeaderLine('Content-Type', 'application/json');
        if ($this->getRequest()->isPost()) {
            $postData = $this->params()->fromPost();
            $fileData = $this->getRequest()->getFiles()->toArray();
            try {
                $response = $this->api(null, true)->create('assets', $postData, $fileData);
                $httpResponse->setContent(json_encode([]));
                            ....

This is the action that should handle “sending the file”, but i don’t see any way i could tweak it.

Someone already managed to do this ?

Thanks

The validation for allowed types is done within that “api” call. Specifically, by the AssetAdapter.

1 Like

It worked! thanks.

For reference, i modified this file : /application/view/omeka/admin/asset/add-form.phtml ; to change the file types allowed on the client side, then the one you said (AssetAdapter) for the server side verification.

Once this is done, it’s still broken because Asset doesn’t have anything to display pdf files, so i did this :

In the file application/view/omeka/admin/asset/browse.phtml
At the line 60
Insert this : <a href=<?php echo $asset->assetUrl(); ?>>Link</a>
This will add the link to the file to each row.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.