Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursively creating directory #246

Closed
mike-sirs opened this issue Sep 25, 2014 · 6 comments
Closed

recursively creating directory #246

mike-sirs opened this issue Sep 25, 2014 · 6 comments
Milestone

Comments

@mike-sirs
Copy link

hello, maybe someone could help me, i can't create new object with new directories like 's3://test/11/55/66/sca.jpeg', only one sub Dir like 's3://test/11/sca.jpg'

get bucket

bucket = s3.buckets["test"]

create a new object

object = bucket.objects.create("11/55/66/sca.jpeg", "value")

show objects in the bucket

bucket.objects.with_prefix("").each do |obj|
p obj
end

retrieve an object

object = bucket.objects["11/55/66/sca.jpeg"]

insert an object

object.write(
file: "/tmp/scan.jpeg"
)

thanks in advance

@mike-sirs mike-sirs changed the title create recursive directory recursively creating directory Sep 25, 2014
@mike-sirs
Copy link
Author

simple correction, object was created, but not displayed in the file list.
s3cmd ls s3://test/
there no Dir 11

@yosukehara
Copy link
Member

Thank you for sharing. I've checked this issue but could not face the same situation as follows:

### Check using OS
$ uname -a
Linux yosuke-optiplex-7010 3.11.0-26-generic #45-Ubuntu SMP Tue Jul 15 04:02:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

### Check s3cmd's version
$ s3cmd --version
s3cmd version 1.1.0-beta3

###Check LeoFS's version and the status
$ ./leofs-adm status
[System config]
                System version : 1.1.3
                    Cluster Id : leofs_1
                         DC Id : dc_1
                Total replicas : 2
           # of successes of R : 1
           # of successes of W : 1
           # of successes of D : 1
 # of DC-awareness replicas    : 0
                     ring size : 2^128
             Current ring hash : 7da7fbe9
                Prev ring hash : 7da7fbe9
[Multi DC replication settings]
         max # of joinable DCs : 2
            # of replicas a DC : 1

[Node(s) state]
-------+--------------------------+--------------+----------------+----------------+----------------------------
 type  |           node           |    state     |  current ring  |   prev ring    |          updated at         
-------+--------------------------+--------------+----------------+----------------+----------------------------
  S    | storage_0@127.0.0.1      | running      | 7da7fbe9       | 7da7fbe9       | 2014-09-26 09:27:46 +0900
  S    | storage_1@127.0.0.1      | running      | 7da7fbe9       | 7da7fbe9       | 2014-09-26 09:27:47 +0900
  S    | storage_2@127.0.0.1      | running      | 7da7fbe9       | 7da7fbe9       | 2014-09-26 09:27:46 +0900
  S    | storage_3@127.0.0.1      | running      | 7da7fbe9       | 7da7fbe9       | 2014-09-26 09:27:47 +0900
  G    | gateway_0@127.0.0.1      | running      | 7da7fbe9       | 7da7fbe9       | 2014-09-26 09:27:48 +0900


### Create a bucket
$ s3cmd mb s3://photo
Bucket 's3://photo/' created

### Put plural objects with ``s3cmd sync``
$ s3cmd sync deps/leo_rpc s3://photo
deps/leo_rpc/.git/HEAD -> s3://photo/leo_rpc/.git/HEAD  [1 of 56]
 41 of 41   100% in    0s     2.96 kB/s  done
deps/leo_rpc/.git/config -> s3://photo/leo_rpc/.git/config  [2 of 56]
 269 of 269   100% in    0s    31.81 kB/s  done
deps/leo_rpc/.git/description -> s3://photo/leo_rpc/.git/description  [3 of 56]
 73 of 73   100% in    0s     8.40 kB/s  done
.
.
.
deps/leo_rpc/test/leo_rpc_tests.erl -> s3://photo/leo_rpc/test/leo_rpc_tests.erl  [56 of 56]
 7593 of 7593   100% in    0s  2033.75 kB/s  done
Done. Uploaded 1022327 bytes in 0.5 seconds, 1987.41 kB/s

### Execute ``s3cmd ls`` [1]
$ s3cmd ls
2014-09-26 00:30  s3://photo

### Execute ``s3cmd ls`` [2]
$ s3cmd la s3://photo
                       DIR   s3://photo/leo_rpc/

### Execute ``s3cmd ls`` [3]
$ s3cmd ls s3://photo/leo_rpc/
                       DIR   s3://photo/leo_rpc/.git/
                       DIR   s3://photo/leo_rpc/.rebar/
                       DIR   s3://photo/leo_rpc/ebin/
                       DIR   s3://photo/leo_rpc/include/
                       DIR   s3://photo/leo_rpc/src/
                       DIR   s3://photo/leo_rpc/test/
2014-09-26 00:30        86   s3://photo/leo_rpc/.gitignore
2014-09-26 00:30      2471   s3://photo/leo_rpc/CHANGELOG.md
2014-09-26 00:30     10175   s3://photo/leo_rpc/LICENSE
2014-09-26 00:30      1129   s3://photo/leo_rpc/Makefile
2014-09-26 00:30      3115   s3://photo/leo_rpc/README.md
2014-09-26 00:30    181045   s3://photo/leo_rpc/rebar
2014-09-26 00:30      1446   s3://photo/leo_rpc/rebar.config

@mike-sirs
Copy link
Author

if you create new object like
object = bucket.objects.create("11/55/66/sca.jpeg", "value")
by ruby or php, object will be available on the gateway, for example by url "http://test.hostname.own:8080/11/55/66/sca.jpeg", but not shown in the bucket list

@yosukehara
Copy link
Member

I'll check this issue with the same way, then share the result.

@yosukehara
Copy link
Member

We've reproduced this issue. Then we're going to fix it and include it in LeoFS v1.1.4 (next version).

# on manager console
leofs-adm add-bucket bbb 05236
leofs-adm update-acl bbb 05236 public-read-write

# on shell
curl -X PUT -v http://localhost:8080/bbb/1/2/3/test.dat -d "leo"

# on shell with s3cmd
### "DIR   s3://bbb/1" to be displayed
[kanno@leofs11 aws-sdk-php]$ s3cmd ls s3://bbb
### "DIR   s3://bbb/1/2" to be displayed
[kanno@leofs11 aws-sdk-php]$ s3cmd ls s3://bbb/1
### Directories are displayed properly when the number of directory is less than 2
[kanno@leofs11 aws-sdk-php]$ s3cmd ls s3://bbb/1/2
                       DIR   s3://bbb/1/2/3/
[kanno@leofs11 aws-sdk-php]$ s3cmd ls s3://bbb/1/2/3
2014-10-01 09:09         4   s3://bbb/1/2/3/test.dat

@yosukehara
Copy link
Member

We've fixed this issue as bellow.
Then we're going to include it in LeoFS v1.1.4.

## Prepare
$ leofs-adm add-bucket bbb 05236
leofs-adm: command not found
$ ./leofs-adm add-bucket bbb 05236
OK
$ ./leofs-adm update-acl bbb 05236 public-read-write
OK

## PUT an object
$ curl -X PUT -v http://localhost:8080/bbb/1/2/3/test.dat -d "leo"
* Adding handle: conn: 0x2547d20
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x2547d20) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /bbb/1/2/3/test.dat HTTP/1.1
> User-Agent: curl/7.32.0
> Host: localhost:8080
> Accept: */*
> Content-Length: 3
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 3 out of 3 bytes
< HTTP/1.1 200 OK
< connection: keep-alive
< date: Thu, 02 Oct 2014 05:41:05 GMT
< content-length: 0
* Server LeoFS is not blacklisted
< server: LeoFS
< ETag: "0f759dd1ea6c4c76cedc299039ca4f23"
< 
* Connection #0 to host localhost left intact

## Check
$ s3cmd ls s3://bbb
                       DIR   s3://bbb/1/
$ s3cmd ls s3://bbb/1
                       DIR   s3://bbb/1/2/
$ s3cmd ls s3://bbb/1/2
                       DIR   s3://bbb/1/2/3/
$ s3cmd ls s3://bbb/1/2/3
2014-10-02 05:41         3   s3://bbb/1/2/3/test.dat

@mocchira mocchira added this to the 1.1.4 milestone Oct 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants