{"id":858,"date":"2022-12-06T15:31:52","date_gmt":"2022-12-06T15:31:52","guid":{"rendered":"http:\/\/wp.chaoyu.nl\/?p=858"},"modified":"2023-05-19T21:52:40","modified_gmt":"2023-05-19T21:52:40","slug":"how-to-upload-folderfiles-into-oracle-oci-buckets","status":"publish","type":"post","link":"https:\/\/chaoyu.nl\/?p=858","title":{"rendered":"How to upload folder(files) into Oracle OCI buckets with CLI"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This method is tested working flawlessly with 69.000 files,120 gb size in total. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install OCI CLI on your local machine where you planning to upload the folders and files ( <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.oracle.com\/en-us\/iaas\/Content\/API\/SDKDocs\/cliinstall.htm#InstallingCLI__macos_homebrew\" data-type=\"URL\" data-id=\"https:\/\/docs.oracle.com\/en-us\/iaas\/Content\/API\/SDKDocs\/cliinstall.htm#InstallingCLI__macos_homebrew\" target=\"_blank\">following this guide<\/a>  Mac Version)<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After Installation, Setting up the Configuration File<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">oci setup config<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here , it requires your <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>user OCID<\/li>\n\n\n\n<li>Tenancy OCID<\/li>\n\n\n\n<li>It will generate a new key pair of use an existing one if you have it already ( do be aware that one OCI user can only have max 3 API keys created, so do consider user existing key)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">After configuration, you can chose to upload your public key to that user (OCID) -&gt; API keys -&gt; add New-&gt; upload Public Key<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run a quick test by list all objects from bucket named &#8220;public&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">oci os object list --bucket-name public<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">At this point, have a good read on the <a href=\"https:\/\/docs.oracle.com\/en-us\/iaas\/tools\/oci-cli\/3.27.1\/oci_cli_docs\/cmdref\/os\/object\/list.html\" data-type=\"URL\" data-id=\"https:\/\/docs.oracle.com\/en-us\/iaas\/tools\/oci-cli\/3.27.1\/oci_cli_docs\/cmdref\/os\/object\/list.html\" target=\"_blank\" rel=\"noreferrer noopener\">official doc <\/a>is recommanded. Things are changing fast on OCI, so have the official doc at hands is always good.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Session Token<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another way is via session token. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\"># for host where browser is available \n$ oci session authenticate  \n# for host where NO browser is available,you first need to a host with browser\n1. authenticate on a pc with browser \n  $ oci session authenticate \n2. Export profile\n  $ oci session export --profile &lt;profile_name&gt; --output-file &lt;output_filename&gt;\n3. scp profile.zip to the host without browser\n4. import \n  $ oci session import --session-archive &lt;path_to_exported_zip&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To refresh a token <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">oci session refresh --profile &lt;profile_name&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">I don&#8217;t really read anywhere how long the session stays valid. However, my experience tells me that it is at least 8 hours. Or probably each $ oci commands will refresh the token. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once your session is established. Run the following code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">oci os object bulk-upload -ns ${mynamespace} -bn ${mybucket} --src-dir ${path\/to\/upload\/directory} --overwrite &gt; logfile.txt\n\n# --overwrite flag overwrites files with the same name in the target bucket\n# &gt; logfile.txt , it will pipe all console outputs to a file call logfile.txt ( optional )\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Read more about this code from official guide <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.oracle.com\/en-us\/iaas\/tools\/oci-cli\/3.18.1\/oci_cli_docs\/cmdref\/os\/object\/bulk-upload.html\" data-type=\"URL\" data-id=\"https:\/\/docs.oracle.com\/en-us\/iaas\/tools\/oci-cli\/3.18.1\/oci_cli_docs\/cmdref\/os\/object\/bulk-upload.html\" target=\"_blank\">here<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This method is tested working flawlessly with 69.000 files,120 gb size in total. Install OCI CLI on your local machine where you planning to upload the folders and files ( following this guide Mac Version) After Installation, Setting up the Configuration File Here , it requires your After configuration, you can chose to upload your&#8230;<\/p>\n","protected":false},"author":1,"featured_media":811,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,11],"tags":[37,36,34,35,38],"class_list":["post-858","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-oci","tag-bucket","tag-buckets","tag-how-to-upload-folderfiles-into-oracle-oci-buckets","tag-oracle-oci","tag-upload-folder"],"_links":{"self":[{"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/posts\/858","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=858"}],"version-history":[{"count":22,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/posts\/858\/revisions"}],"predecessor-version":[{"id":1279,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/posts\/858\/revisions\/1279"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=\/wp\/v2\/media\/811"}],"wp:attachment":[{"href":"https:\/\/chaoyu.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chaoyu.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}