{"action":"created","comment":{"url":"https://api.github.com/repos/storj/storj/pulls/comments/192049839","pull_request_review_id":124744326,"id":192049839,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MjA0OTgzOQ==","diff_hunk":"@@ -5,31 +5,143 @@ package storj\n \n import (\n \t\"context\"\n+\t\"crypto/sha256\"\n+\t\"flag\"\n+\t\"fmt\"\n \t\"io\"\n+\t\"os\"\n+\t\"path\"\n+\t\"path/filepath\"\n+\t\"strconv\"\n \t\"time\"\n \n \t\"github.com/minio/cli\"\n-\n-\t\"github.com/minio/minio/cmd\"\n+\tminio \"github.com/minio/minio/cmd\"\n \t\"github.com/minio/minio/pkg/auth\"\n \t\"github.com/minio/minio/pkg/hash\"\n+\t\"github.com/vivint/infectious\"\n+\n+\t\"storj.io/storj/pkg/eestream\"\n+)\n+\n+var (\n+\tpieceBlockSize = flag.Int(\"piece_block_size\", 4*1024, \"block size of pieces\")\n+\tkey            = flag.String(\"key\", \"a key\", \"the secret key\")\n+\trsk            = flag.Int(\"required\", 20, \"rs required\")\n+\trsn            = flag.Int(\"total\", 40, \"rs total\")\n )\n \n func init() {\n-\tcmd.RegisterGatewayCommand(cli.Command{\n+\tminio.RegisterGatewayCommand(cli.Command{\n \t\tName:            \"storj\",\n \t\tUsage:           \"Storj\",\n \t\tAction:          storjGatewayMain,\n \t\tHideHelpCommand: true,\n \t})\n }\n \n+// getbucketscallback returns the buckets list\n+func (s *storjObjects) getBuckets() (buckets []minio.BucketInfo, err error) {\n+\tbuckets = make([]minio.BucketInfo, len(s.storj.bucketlist))\n+\tfor i, bi := range s.storj.bucketlist {\n+\t\tbuckets[i] = minio.BucketInfo{\n+\t\t\tName:    bi.bucket.Name,\n+\t\t\tCreated: bi.bucket.Created,\n+\t\t}\n+\t}\n+\treturn buckets, nil\n+}\n+\n+// putobjectcallback function handles to add the uploaded file to the bucket's file list structure\n+func (s *storjObjects) uploadFile(bucket, object string, filesize int64, metadata map[string]string) (result minio.ListObjectsInfo, err error) {\n+\tvar fl []minio.ObjectInfo\n+\tfor i, v := range s.storj.bucketlist {\n+\t\t// bucket string comparision\n+\t\tif v.bucket.Name == bucket {\n+\t\t\t/* append the file to the filelist */\n+\t\t\ts.storj.bucketlist[i].filelist.file.Objects = append(\n+\t\t\t\ts.storj.bucketlist[i].filelist.file.Objects,\n+\t\t\t\tminio.ObjectInfo{\n+\t\t\t\t\tBucket:      bucket,\n+\t\t\t\t\tName:        object,\n+\t\t\t\t\tModTime:     time.Now(),\n+\t\t\t\t\tSize:        filesize,\n+\t\t\t\t\tIsDir:       false,\n+\t\t\t\t\tContentType: \"application/octet-stream\",\n+\t\t\t\t},\n+\t\t\t)\n+\t\t\t/* populate the filelist */\n+\t\t\tf := make([]minio.ObjectInfo, len(s.storj.bucketlist[i].filelist.file.Objects))\n+\t\t\tfor j, fi := range s.storj.bucketlist[i].filelist.file.Objects {\n+\t\t\t\tf[j] = minio.ObjectInfo{\n+\t\t\t\t\tBucket:      v.bucket.Name,\n+\t\t\t\t\tName:        fi.Name,\n+\t\t\t\t\tModTime:     fi.ModTime,\n+\t\t\t\t\tSize:        fi.Size,\n+\t\t\t\t\tIsDir:       fi.IsDir,\n+\t\t\t\t\tContentType: fi.ContentType,\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tfl = f\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\tresult = minio.ListObjectsInfo{\n+\t\tIsTruncated: false,\n+\t\tObjects:     fl,\n+\t}\n+\treturn result, nil\n+}\n+\n+// listfilescallback returns the files list for a bucket\n+func (s *storjObjects) getFiles(bucket string) (result minio.ListObjectsInfo, err error) {\n+\tvar fl []minio.ObjectInfo\n+\tfor i, v := range s.storj.bucketlist {\n+\t\tif v.bucket.Name == bucket {\n+\t\t\t/* populate the filelist */\n+\t\t\tf := make([]minio.ObjectInfo, len(s.storj.bucketlist[i].filelist.file.Objects))\n+\t\t\tfor j, fi := range s.storj.bucketlist[i].filelist.file.Objects {\n+\t\t\t\tf[j] = minio.ObjectInfo{\n+\t\t\t\t\tBucket:      v.bucket.Name,\n+\t\t\t\t\tName:        fi.Name,\n+\t\t\t\t\tModTime:     fi.ModTime,\n+\t\t\t\t\tSize:        fi.Size,\n+\t\t\t\t\tIsDir:       fi.IsDir,\n+\t\t\t\t\tContentType: fi.ContentType,\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tfl = f\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\tresult = minio.ListObjectsInfo{\n+\t\tIsTruncated: false,\n+\t\tObjects:     fl,\n+\t}\n+\treturn result, nil\n+}\n+\n func storjGatewayMain(ctx *cli.Context) {\n-\tcmd.StartGateway(ctx, &Storj{})\n+\ts := &Storj{}\n+\ts.createSampleBucketList()\n+\tminio.StartGateway(ctx, s)\n+}\n+\n+//S3BucketList structure\n+type S3BucketList struct {\n+\tbucket   minio.BucketInfo\n+\tfilelist S3FileList\n+}\n+\n+//S3FileList structure\n+type S3FileList struct {\n+\tfile minio.ListObjectsInfo","path":"pkg/miniogw/gateway-storj.go","position":138,"original_position":138,"commit_id":"81afd62d1d55a10931c5dfef59b3b7d371a739b7","original_commit_id":"81afd62d1d55a10931c5dfef59b3b7d371a739b7","user":{"login":"kaloyan-raev","id":468091,"node_id":"MDQ6VXNlcjQ2ODA5MQ==","avatar_url":"https://avatars2.githubusercontent.com/u/468091?v=4","gravatar_id":"","url":"https://api.github.com/users/kaloyan-raev","html_url":"https://github.com/kaloyan-raev","followers_url":"https://api.github.com/users/kaloyan-raev/followers","following_url":"https://api.github.com/users/kaloyan-raev/following{/other_user}","gists_url":"https://api.github.com/users/kaloyan-raev/gists{/gist_id}","starred_url":"https://api.github.com/users/kaloyan-raev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaloyan-raev/subscriptions","organizations_url":"https://api.github.com/users/kaloyan-raev/orgs","repos_url":"https://api.github.com/users/kaloyan-raev/repos","events_url":"https://api.github.com/users/kaloyan-raev/events{/privacy}","received_events_url":"https://api.github.com/users/kaloyan-raev/received_events","type":"User","site_admin":false},"body":"I don't see the benefit of this type. Can't the minio.ListObjectsInfo field be inline the S3BucketList? This will make the code for accessing the objects a little bit shorter.","created_at":"2018-05-31T10:05:18Z","updated_at":"2018-05-31T10:05:19Z","html_url":"https://github.com/storj/storj/pull/57#discussion_r192049839","pull_request_url":"https://api.github.com/repos/storj/storj/pulls/57","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/storj/storj/pulls/comments/192049839"},"html":{"href":"https://github.com/storj/storj/pull/57#discussion_r192049839"},"pull_request":{"href":"https://api.github.com/repos/storj/storj/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/storj/storj/pulls/57","id":190369928,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkwMzY5OTI4","html_url":"https://github.com/storj/storj/pull/57","diff_url":"https://github.com/storj/storj/pull/57.diff","patch_url":"https://github.com/storj/storj/pull/57.patch","issue_url":"https://api.github.com/repos/storj/storj/issues/57","number":57,"state":"open","locked":false,"title":"light client upload file support -V3 gateway","user":{"login":"aligeti","id":34487396,"node_id":"MDQ6VXNlcjM0NDg3Mzk2","avatar_url":"https://avatars0.githubusercontent.com/u/34487396?v=4","gravatar_id":"","url":"https://api.github.com/users/aligeti","html_url":"https://github.com/aligeti","followers_url":"https://api.github.com/users/aligeti/followers","following_url":"https://api.github.com/users/aligeti/following{/other_user}","gists_url":"https://api.github.com/users/aligeti/gists{/gist_id}","starred_url":"https://api.github.com/users/aligeti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aligeti/subscriptions","organizations_url":"https://api.github.com/users/aligeti/orgs","repos_url":"https://api.github.com/users/aligeti/repos","events_url":"https://api.github.com/users/aligeti/events{/privacy}","received_events_url":"https://api.github.com/users/aligeti/received_events","type":"User","site_admin":false},"body":"Integrated eestream's serve-piece functionality","created_at":"2018-05-24T17:48:54Z","updated_at":"2018-05-31T10:05:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"58535fa4e4190c096a9f1f5464f9626a9e736e9d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/storj/storj/pulls/57/commits","review_comments_url":"https://api.github.com/repos/storj/storj/pulls/57/comments","review_comment_url":"https://api.github.com/repos/storj/storj/pulls/comments{/number}","comments_url":"https://api.github.com/repos/storj/storj/issues/57/comments","statuses_url":"https://api.github.com/repos/storj/storj/statuses/81afd62d1d55a10931c5dfef59b3b7d371a739b7","head":{"label":"storj:dev_v3_gateway","ref":"dev_v3_gateway","sha":"81afd62d1d55a10931c5dfef59b3b7d371a739b7","user":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"repo":{"id":128089774,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgwODk3NzQ=","name":"storj","full_name":"storj/storj","owner":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/storj/storj","description":null,"fork":false,"url":"https://api.github.com/repos/storj/storj","forks_url":"https://api.github.com/repos/storj/storj/forks","keys_url":"https://api.github.com/repos/storj/storj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/storj/storj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/storj/storj/teams","hooks_url":"https://api.github.com/repos/storj/storj/hooks","issue_events_url":"https://api.github.com/repos/storj/storj/issues/events{/number}","events_url":"https://api.github.com/repos/storj/storj/events","assignees_url":"https://api.github.com/repos/storj/storj/assignees{/user}","branches_url":"https://api.github.com/repos/storj/storj/branches{/branch}","tags_url":"https://api.github.com/repos/storj/storj/tags","blobs_url":"https://api.github.com/repos/storj/storj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/storj/storj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/storj/storj/git/refs{/sha}","trees_url":"https://api.github.com/repos/storj/storj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/storj/storj/statuses/{sha}","languages_url":"https://api.github.com/repos/storj/storj/languages","stargazers_url":"https://api.github.com/repos/storj/storj/stargazers","contributors_url":"https://api.github.com/repos/storj/storj/contributors","subscribers_url":"https://api.github.com/repos/storj/storj/subscribers","subscription_url":"https://api.github.com/repos/storj/storj/subscription","commits_url":"https://api.github.com/repos/storj/storj/commits{/sha}","git_commits_url":"https://api.github.com/repos/storj/storj/git/commits{/sha}","comments_url":"https://api.github.com/repos/storj/storj/comments{/number}","issue_comment_url":"https://api.github.com/repos/storj/storj/issues/comments{/number}","contents_url":"https://api.github.com/repos/storj/storj/contents/{+path}","compare_url":"https://api.github.com/repos/storj/storj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/storj/storj/merges","archive_url":"https://api.github.com/repos/storj/storj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/storj/storj/downloads","issues_url":"https://api.github.com/repos/storj/storj/issues{/number}","pulls_url":"https://api.github.com/repos/storj/storj/pulls{/number}","milestones_url":"https://api.github.com/repos/storj/storj/milestones{/number}","notifications_url":"https://api.github.com/repos/storj/storj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/storj/storj/labels{/name}","releases_url":"https://api.github.com/repos/storj/storj/releases{/id}","deployments_url":"https://api.github.com/repos/storj/storj/deployments","created_at":"2018-04-04T16:27:18Z","updated_at":"2018-05-30T23:15:07Z","pushed_at":"2018-05-31T04:46:53Z","git_url":"git://github.com/storj/storj.git","ssh_url":"git@github.com:storj/storj.git","clone_url":"https://github.com/storj/storj.git","svn_url":"https://github.com/storj/storj","homepage":null,"size":664,"stargazers_count":35,"watchers_count":35,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":18,"open_issues":13,"watchers":35,"default_branch":"master"}},"base":{"label":"storj:master","ref":"master","sha":"d6ddb65bf8f3eaf1fdde2bedc9149d176645e45e","user":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"repo":{"id":128089774,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgwODk3NzQ=","name":"storj","full_name":"storj/storj","owner":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/storj/storj","description":null,"fork":false,"url":"https://api.github.com/repos/storj/storj","forks_url":"https://api.github.com/repos/storj/storj/forks","keys_url":"https://api.github.com/repos/storj/storj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/storj/storj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/storj/storj/teams","hooks_url":"https://api.github.com/repos/storj/storj/hooks","issue_events_url":"https://api.github.com/repos/storj/storj/issues/events{/number}","events_url":"https://api.github.com/repos/storj/storj/events","assignees_url":"https://api.github.com/repos/storj/storj/assignees{/user}","branches_url":"https://api.github.com/repos/storj/storj/branches{/branch}","tags_url":"https://api.github.com/repos/storj/storj/tags","blobs_url":"https://api.github.com/repos/storj/storj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/storj/storj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/storj/storj/git/refs{/sha}","trees_url":"https://api.github.com/repos/storj/storj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/storj/storj/statuses/{sha}","languages_url":"https://api.github.com/repos/storj/storj/languages","stargazers_url":"https://api.github.com/repos/storj/storj/stargazers","contributors_url":"https://api.github.com/repos/storj/storj/contributors","subscribers_url":"https://api.github.com/repos/storj/storj/subscribers","subscription_url":"https://api.github.com/repos/storj/storj/subscription","commits_url":"https://api.github.com/repos/storj/storj/commits{/sha}","git_commits_url":"https://api.github.com/repos/storj/storj/git/commits{/sha}","comments_url":"https://api.github.com/repos/storj/storj/comments{/number}","issue_comment_url":"https://api.github.com/repos/storj/storj/issues/comments{/number}","contents_url":"https://api.github.com/repos/storj/storj/contents/{+path}","compare_url":"https://api.github.com/repos/storj/storj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/storj/storj/merges","archive_url":"https://api.github.com/repos/storj/storj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/storj/storj/downloads","issues_url":"https://api.github.com/repos/storj/storj/issues{/number}","pulls_url":"https://api.github.com/repos/storj/storj/pulls{/number}","milestones_url":"https://api.github.com/repos/storj/storj/milestones{/number}","notifications_url":"https://api.github.com/repos/storj/storj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/storj/storj/labels{/name}","releases_url":"https://api.github.com/repos/storj/storj/releases{/id}","deployments_url":"https://api.github.com/repos/storj/storj/deployments","created_at":"2018-04-04T16:27:18Z","updated_at":"2018-05-30T23:15:07Z","pushed_at":"2018-05-31T04:46:53Z","git_url":"git://github.com/storj/storj.git","ssh_url":"git@github.com:storj/storj.git","clone_url":"https://github.com/storj/storj.git","svn_url":"https://github.com/storj/storj","homepage":null,"size":664,"stargazers_count":35,"watchers_count":35,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":18,"open_issues":13,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/storj/storj/pulls/57"},"html":{"href":"https://github.com/storj/storj/pull/57"},"issue":{"href":"https://api.github.com/repos/storj/storj/issues/57"},"comments":{"href":"https://api.github.com/repos/storj/storj/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/storj/storj/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/storj/storj/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/storj/storj/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/storj/storj/statuses/81afd62d1d55a10931c5dfef59b3b7d371a739b7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kaloyan-raev"}}