Forum OpenACS Development: Uploading file from OpenACS to different OpenACS Server

I have a file at /tmp/myfile.odt on server 1.

On server 2 I have file-storage installed at server2/file-storage.

I want to upload the file in "myfile.odt" from server1 to server2 using server2/file-storage/file-add

I thought that util_http_file_upload would help, but it does not (and I dont want to work on it too much now knowing if it works in the first place, as noone in the toolkit seems to use it).

Any ideas?

Collapse
Posted by Dave Bauer on
It works fine, but util_http_file_upload can't login.

You'd need to have a form that accepted a secret key to securely use it. But it does generate a correct HTTP POST with a multipart form.

Okay, here is what I call:

util_http_file_upload -file /tmp/hello.odt -name "upload_file" http://cvs.cognovis.de:8080/contacts/convert

The convert page is not protected, feel free to get your PDFs generated the.

And here is the relevant part. If I go to http://cvs.cognovis.de:8080/contacts/convert and do a manual upload everything works fine. If I use my command above, it just returns the normal HTML page with the form.

ad_page_contract {
Download file, convert it to pdf and return it

@param url URL where to get the odt file from
} {
upload_file:trim,optional
return_url:optional
upload_file.tmpfile:tmpfile,optional
url:optional
}

ad_form -name "file-add" -html { enctype multipart/form-data } -export { folder_id lock_title_p name } -form {
{upload_file:file {label \#file-storage.Upload_a_file\#} {html "size 30"}}
} -after_submit {
set upload_files [list [template::util::file::get_property filename $upload_file]]
set oo_file [list [template::util::file::get_property tmp_filename $upload_file]]
}