
{"id":22214,"date":"2024-09-18T15:56:20","date_gmt":"2024-09-18T13:56:20","guid":{"rendered":"https:\/\/contabo.com\/blog\/kb\/103000282879-can-i-automatically-share-files-from-object-storage-publicly\/"},"modified":"2025-04-10T18:05:37","modified_gmt":"2025-04-10T16:05:37","slug":"103000282879-can-i-automatically-share-files-from-object-storage-publicly","status":"publish","type":"kb","link":"https:\/\/contabo.com\/blog\/kb\/103000282879-can-i-automatically-share-files-from-object-storage-publicly\/","title":{"rendered":"Can I Automatically Share Files From Object Storage Publicly?"},"content":{"rendered":"<h4 data-identifyelement=\"475\" dir=\"ltr\"><strong data-identifyelement=\"476\" dir=\"ltr\">Can I automatically share files from Object Storage <strong data-identifyelement=\"479\">publicly<\/strong>? <br data-identifyelement=\"480\"><\/strong><\/h4>\n<p data-identifyelement=\"481\" dir=\"ltr\"><strong>Yes this is possible with the S3 API<\/strong>, you can find the steps on how to set this up below.&nbsp;<\/p>\n<p data-identifyelement=\"482\" dir=\"ltr\"><br data-identifyelement=\"483\"><\/p>\n<h4 data-identifyelement=\"484\" dir=\"ltr\"><strong data-identifyelement=\"485\">How do&nbsp;<\/strong><strong data-identifyelement=\"486\" dir=\"ltr\">I automatically share files from Object Storage <strong data-identifyelement=\"489\">publicly<\/strong>?<\/strong><\/h4>\n<ol data-identifyelement=\"490\">\n<li data-identifyelement=\"491\" dir=\"ltr\">Setup<strong data-identifyelement=\"492\" dir=\"ltr\">&nbsp;<\/strong>your S3 tool. The easiest way is to use <u data-identifyelement=\"493\"><a data-identifyelement=\"494\" href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000305590-what-is-the-aws-cli-tool-\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">aws cli<\/a><\/u>. Please make sure to have it installed and configured properly.&nbsp;<\/li>\n<li data-identifyelement=\"495\" dir=\"ltr\">Create a file public-sharing-policy.json with the following content:<br data-identifyelement=\"497\">{<br data-identifyelement=\"498\">&#8220;Id&#8221;: &#8220;your-fancy-name&#8221;,<br data-identifyelement=\"499\">&#8220;Version&#8221;: &#8220;2012-10-17&#8221;,<br data-identifyelement=\"500\">&#8220;Statement&#8221;: [<br data-identifyelement=\"501\">{<br data-identifyelement=\"502\">&#8220;Action&#8221;: [<br data-identifyelement=\"503\">&#8220;s3:GetObject&#8221;<br data-identifyelement=\"504\">],<br data-identifyelement=\"505\">&#8220;Effect&#8221;: &#8220;Allow&#8221;,<br data-identifyelement=\"506\">&#8220;Resource&#8221;: [<br data-identifyelement=\"507\">&#8220;arn:aws:s3:::foldername\/file&#8221;<br data-identifyelement=\"508\">],<br data-identifyelement=\"509\">&#8220;Principal&#8221;: &#8220;*&#8221;<br data-identifyelement=\"510\">}<br data-identifyelement=\"511\">]<br data-identifyelement=\"512\">}<strong data-identifyelement=\"513\" dir=\"ltr\"><br data-identifyelement=\"514\"><\/strong><\/li>\n<li data-identifyelement=\"516\" dir=\"ltr\">Next you need to enable public Sharing for a folder an all its sub items. To do this Create a file public-sharing-policy.json with following content:<br data-identifyelement=\"517\"><br data-identifyelement=\"518\">\n<pre data-identifyelement=\"519\"><code class=\"codeBlockLines_e6Vv\" data-identifyelement=\"521\">{<br data-identifyelement=\"522\"> \"Id\": \"your-fancy-name\",<br data-identifyelement=\"523\"> \"Version\": \"2012-10-17\",<br data-identifyelement=\"524\"> \"Statement\": [<br data-identifyelement=\"525\"> {<br data-identifyelement=\"526\"> \"Action\": [<br data-identifyelement=\"527\"> \"s3:GetObject\"<br data-identifyelement=\"528\"> ],<br data-identifyelement=\"529\"> \"Effect\": \"Allow\",<br data-identifyelement=\"530\"> \"Resource\": [<br data-identifyelement=\"531\"> \"arn:aws:s3:::foldername\/*\"<br data-identifyelement=\"532\"> ],<br data-identifyelement=\"533\"> \"Principal\": \"*\"<br data-identifyelement=\"534\"> }<br data-identifyelement=\"535\"> ]<br data-identifyelement=\"536\">}<\/code><\/pre>\n<\/li>\n<li data-identifyelement=\"537\" dir=\"ltr\">Please be aware that the S3 Object Storage doesn&#8217;t support file listing in browser. The s3TenantId can be retrieved via the <u data-identifyelement=\"538\"><a data-identifyelement=\"539\" href=\"https:\/\/api.contabo.com\/\" rel=\"noreferrer nofollow noopener\" target=\"_blank\"><u data-identifyelement=\"540\">Contabo API<\/u><\/a><\/u>.<br data-identifyelement=\"541\"><br data-identifyelement=\"542\">The only difference is that you use &#8220;*&#8221;as a wildcard \/ placeholder for the file name. Of course you can have constructs like &#8220;arn:aws:s3:::foldername1\/foldername2\/*&#8221;.<\/li>\n<\/ol>\n<h4 data-identifyelement=\"543\" dir=\"ltr\"><strong data-identifyelement=\"544\">How do I disable public sharing via the S3 API?<\/strong><\/h4>\n<p data-identifyelement=\"545\" dir=\"ltr\">To disable the Public Sharing for a file or folder you need first to get the current policy via:<\/p>\n<p data-identifyelement=\"546\" dir=\"ltr\"><br data-identifyelement=\"547\"><\/p>\n<pre data-identifyelement=\"548\" dir=\"ltr\">aws --profile eu2 --endpoint-url https:\/\/eu2.contabostorage.com s3api get-bucket-policy --bucket foo<\/pre>\n<p data-identifyelement=\"550\" dir=\"ltr\">Then remove the parts you would like to remove and do the put-bucket-policy again with the modified file. If it is the last entry in there you could also delete it completely via:<br data-identifyelement=\"551\"><br data-identifyelement=\"552\"><\/p>\n<pre data-identifyelement=\"553\"><code class=\"codeBlockLines_e6Vv\" data-identifyelement=\"555\">aws --profile eu2 --endpoint-url https:\/\/eu2.contabostorage.com s3api delete-bucket-policy --bucket foo<\/code><\/pre>\n<p data-identifyelement=\"557\" dir=\"ltr\">But be cautious as this will delete all policies on that bucket.<\/p>\n<\/p>\n<p><span class=\"ast-load-more active\"><a href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000282879-can-i-automatically-share-files-from-object-storage-publicly-\" rel=\"nofollow\">Details&#8230;<\/a> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can I automatically share files from Object Storage publicly? Yes this is possible with the S3 API, you can find the steps on how to set this up below.&nbsp; How do&nbsp;I automatically share files from Object Storage publicly? Setup&nbsp;your S3 tool. The easiest way is to use aws cli. Please make sure to have it [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"template":"","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2067],"tags":[],"class_list":["post-22214","kb","type-kb","status-publish","hentry","category-kb"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Contabo Web","author_link":"https:\/\/contabo.com\/blog\/author\/julius-nalivaiko\/"},"uagb_comment_info":0,"uagb_excerpt":"Can I automatically share files from Object Storage publicly? Yes this is possible with the S3 API, you can find the steps on how to set this up below.&nbsp; How do&nbsp;I automatically share files from Object Storage publicly? Setup&nbsp;your S3 tool. The easiest way is to use aws cli. Please make sure to have it&hellip;","_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"version-history":[{"count":1,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22214\/revisions"}],"predecessor-version":[{"id":22922,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22214\/revisions\/22922"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=22214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=22214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=22214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}