King0770-Notes-Bulk Upload To Briefcase


Description: This wiki will hopefully answer the question, "How do upload a bunch of files to a user's briefcase?"

From a remote machine

If you wish to upload files from a remote server to the Zimbra server, you could use curl to upload.

Here's an example of uploading a single file:

curl -u zimbra_user:zimbra_user_password --data-binary "@/mp3/Let it be.mp3" http://zimbra.domain.com/service/home/zimbra_user/Briefcase/Let_it_be.mp3

You can use DAV too :

curl -u zimbra_user:zimbra_user_password -T "/mp3/Let it be.mp3" http://zimbra.domain.com/dav/zimbra_user/Briefcase/


You'll note I've put double quotes around "@/mp3/Let it be.mp3", because the file name contains spaces. I tried putting double quotes around the Zimbra address with a file that had spaces, but it didn't seem to work for me. The only way to upload was successful, was to put underscores in the filename. Perhaps curl doesn't like file names with spaces.

You should be able to run a for loop to upload files to a user's briefcase:
I had found the following worked for me.

for i in `ll | awk '{ print $9 }'`; do curl -u zimbra_user:zimbra_user_password --data-binary "@/docs/$i" http://zimbra.domain.com/service/home/zimbra_user/Briefcase/$i; done

If you had already worked out the "files with spaces" issues, this command should be sufficient.

From the Zimbra machine

If there a bunch of files you wish to upload to a user's briefcase from the Zimbra machine, the following command examples should help.

Single File

zmmailbox -z -m user1@domain.com postRestURL --contentType application/msword "/Briefcase/Letter.doc" "/tmp/documents/Letter.doc"

Multiple Files

for i in `ll | awk '{ print $9 }'`; do zmmailbox -z -m user1@domain.com postRestURL --contentType application/msword /Briefcase/"$i" /tmp/documents/"$i"; done

If you wish to distinguish the different file types, you might want to run the for loop on all files with the sames extension. This way you don't have to keep switching the "--contentType" setting.

Jump to: navigation, search