[opencms-dev] How to upload multiple files and set content/file type?

Mario Jäger m.jaeger at alkacon.com
Wed Oct 13 08:30:46 CEST 2010



Hi,

Yes, you have to control that with one suffix per resource type. Your example ".typea_html" does work. You can not configure a mapping with suffix "typea.html".

The calculating of the default resource type for the given file name is done in org.opencms.loader.CmsResourceManager.getDefaultTypeForName(). There, the extension of the file name is calculated to find the associated mapping.
And the extension is the string with the last dot in the file name. If you have a file name "instance1.typea_html", the calculated extension is ".typea_html". And that does match your mapping with suffix ".typea_html". If you
have a file name "instance1_typea.html", then the calculated extension of the file name is ".html". And that does not match the mapping with suffix "typea.html".

-- 
Kind Regards,
Mario.

-------------------
Mario Jäger

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org


Am 12.10.2010 11:29, schrieb florimodo:
> Thanks for your help!
> So I can map one file extension to only one content type!?
> I my case, all content types do have the suffix "html", so if I would
> like to map documents of content type "TypeA" I had to introduce a new
> suffix like ".typea_html" or could I also create a mapping for
> "typea.html"  so all documents with a name "*typea.html" (e.g.
> "instance1_typea.html") would be mapped to that type.
>
>
> Am 12.10.2010 10:49, schrieb Mario Jäger:
>> Hi,
>>
>> You upload a zip file into OpenCms with the selected checkbox "Unzip file". In this case, the resource types, which are created are mapped with the extensions of the files in the zip file. The mapping between
>> the extension and the resource type for the default resource types is configured in the WEB-INF/config/opencms-vfs.xml. For example, the extension ".html" is mapped with resource type "plain" per default:
>>
>> ...
>> <resourcetypes>
>>     ...
>>     <type class="org.opencms.file.types.CmsResourceTypePlain" name="plain" id="1">
>>       <mappings>
>>         ...
>>         <mapping suffix=".html" />
>>         ...
>>
>> That means, that there are created resources of type "plain" for files with name "*.html" in a zip file.
>>
>>
>> For example, if you want, that there are created resources of type "photoalbum" for files with name "*.html" in a zip file, then you have to add the<mappings>   node for the module "org.opencms.frontend.photoalbum" in the
>> WEB-INF/config/opencms-modules.xml:
>>
>> ...
>> <module>
>>     <name>org.opencms.frontend.photoalbum</name>
>>     ...
>>     <resourcetypes>
>>       <type class="org.opencms.file.types.CmsResourceTypeXmlContent" name="photoalbum" id="55">
>>         <mappings>
>>           <mapping suffix=".html" />
>>         </mappings>
>>         ...
>>
>> And you have to remove the mapping between the "*.html" files and the resource type "plain" in the WEB-INF/config/opencms-vfs.xml:
>>
>> ...
>> <type class="org.opencms.file.types.CmsResourceTypePlain" name="plain" id="1">
>>     <mappings>
>>       ...
>>       <!--<mapping suffix=".html" />-->
>>       ...
>>
>>
>> After that, you have to restart your servlet container.
>>
>>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list