🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
4 messages
4 total messages Started by Venkateswara_Rao Mon, 19 Jan 2009 18:05
How to upload a file
#1825
Author: Venkateswara_Rao
Date: Mon, 19 Jan 2009 18:05
19 lines
1097 bytes
Hi,

I am working on a project which uses remote indesign server.

The javascript is executed at remote end and retrieves the file using java servlet.

var http1 = new HttpConnection("http://192.168.1.20:8080/servlet/getFileServlet?id=10");
http1.response = new File("test.indd") ;
http1.execute() ;
http1.response.close() ;

after downloading the file I am converting indesign file to PDF. Now I have to upload this PDF to my java server using a fileupload servlet.

How I can achieve this using HttpConnection ?

Please help. Thanks.

Regards,
Venky
Re: How to upload a file
#1750
Author: Tino Runtzler
Date: Fri, 23 Jan 2009 16:45
7 lines
993 bytes
Hi Venkateswara Rao,

ok, where do you get HttpConnection from? Didn't find it in Core JavaScript Classes as well as in Adobe Indesign CS3 Classes?! Or is it an own written wrapper object?

To call a fileupload servlet, you could painfully implement http, ftp, smtp, .. on your own by using the Socket object from Core JavaScript Classes. I did this approach for http as well as smtp.

Cheers Tino
Re: How to upload a file
#1795
Author: Venkateswara_Rao
Date: Tue, 27 Jan 2009 07:38
16 lines
1039 bytes
Hi Cheers Tino,

I found HttpConnection in Javascript CS3 tools guide.
(javascript_tools_guide_cs3.pdf)

I was able to download a file from server using HttpConneciton, but unable to upload file to server using it.

I tried bunch of things creating "HTTP 1.1/ POST" packet, but
nothing worked. I am very new to this kind of packet creation."

Can you please provide me with the file upload script.

Your help is greatly appreciated.

Regards,
Venky
Re: How to upload a file
#1694
Author: Tino Runtzler
Date: Wed, 04 Feb 2009 07:50
82 lines
3756 bytes
Hi Venky,

unfortunately i must admit, that i did found a solution for uploading a file neather with HttpConnection nor with Socket.

I tried the following:

1. Setup a servlet for uploading, build a small HTTP form and inspect the HTTP-Header:

Form:
[code]
	File:
	

[/code]

HTTP-Header(truncated, only first bytes displayed):
POST /FileUploadServlet/FileUploader HTTP/1.1
Host: localhost:7070
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: <http://localhost:7070/FileUploadServlet/index.jsp>
Cookie: JSESSIONID=0359fed1cc75cb347491ac227deb; _csuid=49057dd60a38b213
Content-Type: multipart/form-data; boundary=---------------------------41184676334
Content-Length: 37953

-----------------------------41184676334
Content-Disposition: form-data; name="uploadFile"; filename="mytestpicture.jpg"
Content-Type: image/jpeg

��� ...

This upload works fine, the servlet get the right information to save the uploaded file.

2. Try to upload a file with HttpConnection

var http = new HttpConnection("http://localhost:7070/FileUploadServlet/FileUploader" ) ;
var fileToTransfer = new File("mytestpicture.jpg") ;
http.requestheaders = ["Keep-Alive" , "300"] ;
http.method = "POST";
http.mime = "multipart/form-data;";
http.chunked = false;
http.request = fileToTransfer;
http.execute();

This doesn't work. The HttpConnection doesn't write any boundary or Content-Disposition information, so the servlet can't find the file content.

3. Try to upload afile with Socket

var conn = new Socket();
conn.open("localhost:7070");
conn.timeout=300;
conn.writeln("POST /FileUploadServlet/FileUploader HTTP/1.1");
conn.writeln("Host: localhost:7070");
conn.writeln("Keep-Alive: 300");
conn.writeln("Connection: keep-alive");
conn.writeln("Referer: <http://localhost:7070/FileUploadServlet/>");
conn.writeln("Content-Type: multipart/form-data; boundary=---------------------------1255014013694");
conn.writeln("Content-Length: 211");
conn.writeln("");
conn.writeln("-----------------------------1255014013694");
conn.writeln('Content-Disposition: form-data; name="uploadFile"; filename="test.txt"');
conn.writeln("Content-Type: text/plain");
conn.writeln("");
conn.writeln("test");
conn.write("-----------------------------1255014013694--");
var i=1;
while(!conn.eof) {
  $.writeln(i + ":" + conn.eof + ":" + conn.readln());
  ++i;
};
conn.close();

This doesn't work. I tried to define an own boundary and set the Content-Disposition etc. by myself. For testing i used in this case no binary but a text file.

So Venky, perhaps i inspired you on further examination. Or perhaps Robin Mills got an idea on this issue (http://www.clanmills.com/robin.shtml) ;-) or any forum guru?!

Cheers Tino
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads