I'm writing an app that needs to use java to recoeve a small upload, and attach it to several issues (upload can be duplicated if necessary). I have created a handler servlet, but I'm struggeling with finding the proper API classes that handle the attachment code.
does Jira have a temp folder thats suitable for uploading to?
where should the file end up?
which classes handle file upload?
Thanks for your help...
1)
You probably need:
MultiPartRequestWrapper mprw = (MultiPartRequestWrapper) ServletActionContext.getMultiPartRequest(); if (mprw!=null && mprw.getFileNames().hasMoreElements()) { byte[] data=null; Enumeration<String> fileNames = mprw.getFileNames(); if (fileNames.hasMoreElements()) { while(fileNames.hasMoreElements()) { String fileName = fileNames.nextElement(); File file = mprw.getFile(fileName); ...
2)
Try getting ComponentAccessor.getComponent(JiraHome.class);
That will give you .getDataDirectory() , which is your JIRA_HOME/data folder, allowing you to create a temp file in JIRA_HOME/tmp or your own location.
Any Ideas on how to programatically attach a File object to an issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
points encourage additional answers :) You need to create an attachment.
AttachmentManager attachmentManager = ComponentManager.getInstance().getAttachmentManager();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for some reason, the ...
MultiPartRequestWrapper mprw = (MultiPartRequestWrapper) ServletActionContext.getMultiPartRequest();
is resolving to null?
is there something special I need in my servlet config?
<servlet name="dataHandler" key="bamHandler" class="com.foo.BarServlet"> <description></description> <url-pattern>/dataHandler</url-pattern> </servlet>
Thanks again :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For some reasong the mprw is comming back null? any ideas?
MultiPartRequestWrapper mprw = ServletActionContext.getMultiPartRequest();
Also, is there something special I need in my servlet config to support MultiPart Requests?
<servlet name="dataHandler" key="bamHandler" class="com.foo.BarServlet"> <description></description> <url-pattern>/dataHandler</url-pattern> </servlet>
Thanks again :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for some reason, the ...
MultiPartRequestWrapper mprw = (MultiPartRequestWrapper) ServletActionContext.getMultiPartRequest();
is resolving to null?
is there something special I need in my servlet config?
<servlet name="dataHandler" key="bamHandler" class="com.foo.BarServlet"> <description></description> <url-pattern>/dataHandler</url-pattern> </servlet>
Thanks again Andy :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Uh no, the ServletActionContext is part of webwork, well, it may be a utiloity class, but I've only used it inside an action. The patter to use is [HTML form] -> posts -> [Action] from which the above code works to extract the posted data.
Not to say your approach woudn't work, but Ive not had a compelling reason to even try, this works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.