Ask Your Question

directories creation random problem

asked 2014-06-18 06:27:33 -0500

anonymous user


updated 2014-06-20 16:33:54 -0500

smaffulli gravatar image

Im doing application that upload folder and file recursively to openstack swift but sometimes some folder the openstack say that is created correctly but its wrong if i find with JSON i get at element like


The directories that created correcly i see 2 elements,subdir element and normal element with content type application/directory, date.... etc

If I try to re upload the folder that is wrong, the openstack create correctly the folder. I think is a problem with threads, i put my MKDIR method sync but the problem persist, it's possible openstack need some time to sync the directory creation?

Any idea whats wrong? Sorry for my bad english

edit retag flag offensive close merge delete


I would suggest you to edit your question and add links to the code you're using and check the logs for errors.

smaffulli gravatar imagesmaffulli ( 2014-06-20 16:34:48 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-06-23 04:10:29 -0500

segator gravatar image

The code is large, i copy the "MKDIR" Method

public synchronized boolean mkdir() {
    try {
        String mkdir = realHomeDir + virtualFullPath;
        System.out.println("Client:MKDIR " + mkdir);
        HttpURLConnection connection = conexionURL("PUT", mkdir);
        connection.setRequestProperty("Content-Length", "0");
        connection.setRequestProperty("Content-Type", "application/directory");
        boolean retorno = connection.getResponseCode() == 201;
        System.out.println("Server:MKDIR " + connection.getResponseCode());
        return retorno;
    } catch (Exception ex) {
        return false;
private HttpURLConnection conexionURL(String metodo, String path) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnsupportedEncodingException, MalformedURLException, IOException {
    path = FileUtils.deleteRootSlash(path);
    HttpURLConnection connection = (HttpURLConnection) new URL(authClient.getEndURL().toString().concat("/default/").concat(URLParamEncoder.URLencoding(path, "UTF-8").replace("%2F", "/").replace("&", "%26"))).openConnection();
    System.out.println(metodo + ":" + connection.getURL().toString());
    connection.setRequestProperty("X-Auth-Token", authClient.getTokenAuth());
    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.setRequestProperty("Cache-Control", "no-cache");
    return connection;

The URL Creation method work perfect

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools


Asked: 2014-06-18 06:27:33 -0500

Seen: 135 times

Last updated: Jun 23 '14