Dear Dave,

Thank you for your reply.

> Looks like you do not have a collection that accepts images.

> Go to your Server Admin page and make sure that you have "images/*" or
> "images/gif" in your list of valid extensions for file upload.


I changed permission for file upload. After that, I was able to post
GIF files to sub-directory by using the following code.

---
import java.util.List;
import com.sun.syndication.propono.atom.client.AtomClientFactory;
import com.sun.syndication.propono.atom.client.ClientAtomService;
import com.sun.syndication.propono.atom.client.ClientCollection;
import com.sun.syndication.propono.atom.client.ClientMediaEntry;
import com.sun.syndication.propono.atom.client.ClientWorkspace;
import java.io.FileInputStream;

public class AtomMediaEntryPoster {

    public static void main(String[] args) throws Exception {
        String uri         = args[0];
        String username    = args[1];
        String password    = args[2];
        String title       = args[3];
        String slug        = args[4];
        String contentType = args[5];
        String filepath    = args[6];
        String subdir      = args[7];

        ClientAtomService service =
AtomClientFactory.getAtomService(uri, username, password);
        ClientWorkspace workspace = null;
        List workspaces = service.getWorkspaces();
        workspace = (ClientWorkspace)workspaces.get(0);

        List collections = workspace.getCollections();
        for(int i=0; i<collections.size(); i++){
            ClientCollection collection = (ClientCollection)collections.get(i);
            if(collection.getHref().equals(uri + "/" + username + "/"
+ subdir)){
                ClientMediaEntry entry =
collection.createMediaEntry(title, slug, contentType, new
FileInputStream(filepath));
                collection.addEntry(entry);
            }
        }
    }
}
---

Thank you for your support. (^-^)/

Best regards,

-- 
Tatsuya Noyori (^o^)/

Reply via email to