Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-01-2009, 05:26 AM
Junior Member
 
Posts: 8
Default [SOLVED] Adding uploaded document to mail

Hello,

My zimlet has JS and JSP
1) in compose view, JS is calling JSP with a file path(local drive)
2) JSP uploading the file to server (/service/upload?fmt=raw)
and it returns as:

200,'null','013afbb0-7c77-494d-b078-b6029d784abd:30d2388f-9d18-42fc-abdd-c414c4b86968'

here,
------
httpStatus = 200
client_token = null
server_token = '013afbb0-7c77-494d-b078-b6029d784abd:30d2388f-9d18-42fc-abdd-c414c4b86968'

Now i have to add this uploaded document to my mail. Here i am confused what to do.

i used in js as below:
-----------------------
msg.setSubject("Message subject test");
msg.addAttachmentId(server_token);

on sendMsg i got below error:
--------------------------------
method: SendMsgRequest
msg: upload not found: '8fdb85f4-d9f3-4d96-a40c-966ef55ddebc:13c8f7cf-b8c0-4955-8663-a07cafe7044e'
code: mail.NO_SUCH_UPLOAD
detail: soap:Sender
trace: btpool0-0:1251799378674:8620ef4fcc63768f
request:

Please suggest what to do.
Reply With Quote
  #2 (permalink)  
Old 09-04-2009, 11:28 PM
Junior Member
 
Posts: 8
Default

I have solved it and the issue was that server_token returned from server as prefixed ans suffixed with single quote(').

I removed and followed the below code:
Reply With Quote
  #3 (permalink)  
Old 09-14-2009, 06:54 AM
Intermediate Member
 
Posts: 20
Default

Quote:
Originally Posted by pramodkrjsr View Post
I have solved it and the issue was that server_token returned from server as prefixed ans suffixed with single quote(').

I removed and followed the below code:
Hi
am also trying out a zimlet where il be uploading some document to another server from my local hard disk .

But presently what i am doing is in 2 Steps.
1> Uploading the doc to zimbra Temp folder(of my own)
2>Uploading the Temp File to the Other Server .

My Question is how to directly do the same from the Zimlet without any Temp File Step .
Reply With Quote
  #4 (permalink)  
Old 09-17-2009, 12:36 AM
Junior Member
 
Posts: 8
Default

Hello,

As per my understanding:
You are trying to upload a local file (i.e. c:\temp\my.txt) to another server (ABC.com).


NOw i am sure your another server must have some servlet to accept uploaded files:

Now please follow below steps:

1) from zimlet JS, accept the local file path (via some dialog)
2) call a JSP by passing this file path
3) now make a PostMethod call to your server (using commons-httpclient)

JSP Sample:
=========
PostMethod filePost = new PostMethod("http://www.abc.com/upload");
filePost.getParams().setBooleanParameter(HttpMetho dParams.USE_EXPECT_CONTINUE, false);

Part[] parts = {new FilePart(filename,filename,new File(filepath))};
filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));

HttpClient client = new HttpClient();
client.getHttpConnectionManager().getParams().setC onnectionTimeout(5000);

// Perform the request
int status = client.executeMethod(filePost);

// Use response to generate data for the zimlet
if (status == HttpStatus.SC_OK) {
String[] serverResponseArr = filePost.getResponseBodyAsString().split(",");
} else {
out.println("Error: " + HttpStatus.getStatusText(status));
}
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0