AW: [opencms-dev] Writing images to the CMS (code attached)

Andreas Zahner A.Zahner at alkacon.com
Fri Oct 24 16:29:03 CEST 2003


Matthew,
 
you should change to an offline project before writing to the OpenCms
VFS. Use "cmso.getRequestContext().setCurrentProject(projectId)" to do
so. Get the project ID from the source code of the head frame of the
OpenCms workplace.
 
Regards,

Andreas Zahner
Alkacon Software - The OpenCms Experts
http://www.alkacon.com <http://www.alkacon.com/>  

-----Ursprüngliche Nachricht-----
Von: opencms-dev-admin at opencms.org
[mailto:opencms-dev-admin at opencms.org] Im Auftrag von Matthew Evans
Gesendet: Freitag, 24. Oktober 2003 14:45
An: opencms-dev at opencms.org
Betreff: [opencms-dev] Writing images to the CMS (code attached)


Hi all,
 
I have been working on this bug for about 4 days now, and it's driving
me nuts.
I've tried to follow all the tutorials and information I can find, but
it keeps coming back with errors.
 
I'm trying to simply write an image to the CMS. I've simplified my code
in order to debug, and this is what I have now.
Anyone should be able to run this, just dump it in a jsp file, it loads
the login image and saves it out as test.gif.
Well, thats what it should do, but I keep getting this error:
 
com.opencms.core.CmsException: 1 Access denied. Detailed error:
[com.opencms.file.mySql.CmsResourceBroker] /system/login/test.gif. 
 
Any help would be extremely appreciated.
 
M at .
 
------------------------------- code ----------------------------------
 
<%@ page session="false" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ page import="java.util.*,
                 com.opencms.flex.jsp.*,
                 com.opencms.file.*,
                 com.opencms.core.CmsException" %>
 
<%   
//Get command line parameters
String download_dir = request.getParameter("download_dir");
 
// Create a JSP action element
com.opencms.flex.jsp.CmsJspActionElement cms = new
com.opencms.flex.jsp.CmsJspActionElement(pageContext, request,
response);
 
//Instatiate the CMSObject
CmsObject cmso = cms.getCmsObject(); 
CmsFolder currentFolder = cmso.readFolder(download_dir);
 
//Create properties hash
Hashtable props = new Hashtable(); 
props.put("Title","Test"); 
props.put("Description","Thumbnail for Test");    
 
try{
 
    byte[] jpeg =
cmso.readFile("/system/login/login_logo.gif").getContents();
    CmsFile outputResource =
(CmsFile)cmso.createResource("/system/login/", "test.gif", "image",
props, jpeg);
 
    //Lock the file (should not be needed for new files)
    //cmso.lockResource("/system/login/test.gif");
 
    cmso.writeFile(outputResource);
 
} catch (Exception main) { out.println(main);}
 

%> 
 
 
Matthew Evans
SolidStateGroup
tel. +44 (0) 20 77402133
Mob. +44(0)7958 379562
http://www.solidstategroup.com <http://www.solidstategroup.com/> 
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20031024/0b967808/attachment.htm>


More information about the opencms-dev mailing list