[opencms-dev] Writing images to the CMS (code attached)
Hartmann, Waehrisch & Feykes GmbH
hartmann at waehrisch-feykes.de
Fri Oct 24 16:28:01 CEST 2003
Hi Matthew,
you can find the explanation and solution here:
http://mail.opencms.org/pipermail/opencms-dev/2003q4/007488.html
Bye,
Stephan
----- Original Message -----
From: Matthew Evans
To: opencms-dev at opencms.org
Sent: Friday, October 24, 2003 3:45 PM
Subject: [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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20031024/b79c9b50/attachment.htm>
More information about the opencms-dev
mailing list