295 lines
8.0 KiB
HTML
295 lines
8.0 KiB
HTML
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Js - Minio Client Documentation</title>
|
|
|
|
|
|
|
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
|
|
|
|
<link rel="stylesheet" href="../../../css/theme.css" type="text/css" />
|
|
<link rel="stylesheet" href="../../../css/theme_extra.css" type="text/css" />
|
|
<link rel="stylesheet" href="../../../css/highlight.css">
|
|
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
|
|
<script type="text/javascript" src="../../../js/highlight.pack.js"></script>
|
|
<script src="../../../js/theme.js"></script>
|
|
<script src="../../../sdks/js/example-bucket-policy.js"></script>
|
|
<script src="../../../sdks/js/example-list.js"></script>
|
|
|
|
<style>
|
|
body {font-size: 90%;}
|
|
pre, code {font-size: 100%;}
|
|
h3, h4, h5, h6 {color: #2980b9; font-weight: 300}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
|
<div class="wy-side-nav-search">
|
|
<a href="../../.." class="icon icon-home"> Minio Client Documentation</a>
|
|
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
<ul class="current">
|
|
|
|
|
|
<span>Commands</span>
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../../commands/config">config</a>
|
|
|
|
</li>
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../../commands/ls">ls</a>
|
|
|
|
</li>
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../../commands/cp">cp</a>
|
|
|
|
</li>
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../../commands/mb">mb</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<span>SDKs</span>
|
|
|
|
<li class="toctree-l1 current">
|
|
<a class="current" href=".">Js</a>
|
|
|
|
<ul>
|
|
|
|
<li class="toctree-l2"><a href="#using-aws-sdk-for-javascript">Using AWS SDK for Javascript</a></li>
|
|
|
|
<li><a class="toctree-l3" href="#install">Install</a></li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../python/python">Python</a>
|
|
|
|
</li>
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../ruby/ruby">Ruby</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../../contributing">Contributing</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="toctree-l1 ">
|
|
<a class="" href="../../../debugging">Debugging</a>
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
<i data-toggle="wy-nav-top" class="icon icon-reorder"></i>
|
|
<a href="../../.."></a>
|
|
</nav>
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="../../..">Docs</a> »</li>
|
|
<li>Js</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main">
|
|
<div class="section">
|
|
<h1 id="using-aws-sdk-for-javascript">Using AWS SDK for Javascript</h1>
|
|
<h2 id="install">Install</h2>
|
|
<h3 id="in-nodejs">In Node.js</h3>
|
|
<pre><code>npm install aws-sdk
|
|
</code></pre>
|
|
|
|
<h3 id="example-getservice-and-listobjects">Example <code>GetService</code> and <code>ListObjects</code></h3>
|
|
<pre><code>'use strict'
|
|
|
|
var AWS = require('aws-sdk');
|
|
|
|
var config = {
|
|
accessKeyId: "ECHB22VEKH5I0X4K2T7P",
|
|
secretAccessKey: "IiqhtimkamPZJtV4J8jztm74LpdTSbn7RUASyPzjje2+pfhLJ7nFRg==",
|
|
endpoint: "localhost:9000",
|
|
region: "",
|
|
sslEnabled: false,
|
|
s3ForcePathStyle: true,
|
|
};
|
|
|
|
AWS.config.update(config);
|
|
|
|
var s3 = new AWS.S3();
|
|
s3.listBuckets(function(err, data) {
|
|
if (err) {
|
|
console.log(err); // an error occurred
|
|
} else {
|
|
console.log(data); // successful response
|
|
}
|
|
});
|
|
|
|
|
|
var params = {
|
|
Bucket: "docs"
|
|
};
|
|
|
|
s3.listObjects(params, function(err, data) {
|
|
if (err) console.log(err);
|
|
else console.log(data);
|
|
});
|
|
</code></pre>
|
|
|
|
<p>Grab it here <a href="https://github.com/Minio-io/mc/blob/master/docs/sdks/js/example-list.js">example-list.js</a></p>
|
|
<h3 id="example-getbucketpolicy-and-putbucketpolicy">Example <code>GetBucketPolicy</code> and <code>PutBucketPolicy</code></h3>
|
|
<pre><code>'use strict'
|
|
|
|
var AWS = require('aws-sdk');
|
|
|
|
var config = {
|
|
accessKeyId: "ECHB22VEKH5I0X4K2T7P",
|
|
secretAccessKey: "IiqhtimkamPZJtV4J8jztm74LpdTSbn7RUASyPzjje2+pfhLJ7nFRg==",
|
|
endpoint: "localhost:9000",
|
|
region: "",
|
|
sslEnabled: false,
|
|
s3ForcePathStyle: true,
|
|
};
|
|
|
|
AWS.config.update(config);
|
|
|
|
var s3 = new AWS.S3();
|
|
|
|
var statement = {
|
|
Sid: "ExampleStatemenent1",
|
|
Effect: "Allow",
|
|
Principal: {
|
|
AWS: "minio::1111111:murphy"
|
|
},
|
|
Action: [
|
|
"minio:ListBucket",
|
|
"minio:GetObject",
|
|
"minio:PutObject",
|
|
],
|
|
Resource: [
|
|
"minio:::examplebucket"
|
|
]
|
|
}
|
|
|
|
var policy = {
|
|
Version: "2012-10-20",
|
|
Statement: [statement],
|
|
}
|
|
|
|
var params = {
|
|
Bucket: 'docs',
|
|
Policy: JSON.stringify(policy),
|
|
}
|
|
|
|
s3.putBucketPolicy(params, function(err, data) {
|
|
if (err) {
|
|
console.log(err);
|
|
} else {
|
|
console.log(data);
|
|
}
|
|
});
|
|
|
|
var params = {
|
|
Bucket: 'docs'
|
|
};
|
|
|
|
s3.getBucketPolicy(params, function(err, data) {
|
|
if (err) {
|
|
console.log(err);
|
|
} else {
|
|
console.log(data);
|
|
}
|
|
});
|
|
</code></pre>
|
|
|
|
<p>Grab it here <a href="https://github.com/Minio-io/mc/blob/master/docs/sdks/js/example-bucket-policy.js">example-bucket-policy.js</a></p>
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="../../python/python" class="btn btn-neutral float-right" title="Python"/>Next <span class="icon icon-circle-arrow-right"></span></a>
|
|
|
|
|
|
<a href="../../../commands/mb" class="btn btn-neutral" title="mb"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
<!-- Copyright etc -->
|
|
</p>
|
|
</div>
|
|
|
|
Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
<div class="rst-versions" role="note" style="cursor: pointer">
|
|
<span class="rst-current-version" data-toggle="rst-current-version">
|
|
|
|
<span><a href="../../../commands/mb" style="color: #fcfcfc;">« Previous</a></span>
|
|
<span style="margin-left: 15px"><a href="../../python/python" style="color: #fcfcfc">Next »</a></span>
|
|
</span>
|
|
</div>
|
|
</body>
|
|
</html> |