feature (minio): integrate support for minio in the S3 backend - #62

This commit is contained in:
Mickael KERJEAN
2018-05-14 22:27:31 +10:00
parent 9ba9067a99
commit 7e30bdceb7
4 changed files with 15 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<p align="center"> <p align="center">
A Dropbox-like file manager that let you manage your data anywhere it is located:<br> A Dropbox-like file manager that let you manage your data anywhere it is located:<br>
FTP • SFTP • WebDAV • Git • S3 <br> FTP • SFTP • WebDAV • Git • S3 • Minio <br>
Dropbox • Google Drive Dropbox • Google Drive
</p> </p>
<p align="center"> <p align="center">

View File

@ -67,7 +67,7 @@ export class Form extends React.Component {
if(credentials['webdav'] && credentials['webdav']['path']){ if(credentials['webdav'] && credentials['webdav']['path']){
this.setState({advanced_webdav: true}); this.setState({advanced_webdav: true});
} }
if(credentials['s3'] && credentials['s3']['path']){ if(credentials['s3'] && (credentials['s3']['path'] || credentials['s3']['endpoint'])){
this.setState({advanced_s3: true}); this.setState({advanced_s3: true});
} }
if(credentials['git'] && ( if(credentials['git'] && (
@ -304,6 +304,9 @@ export class Form extends React.Component {
<NgIf cond={this.should_appear('s3', 'path')}> <NgIf cond={this.should_appear('s3', 'path')}>
<Input type={this.input_type('s3', 'path')} name="path" placeholder="Path" ref={(input) => {this.state.refs.s3_path = input; }} autoComplete="new-password" /> <Input type={this.input_type('s3', 'path')} name="path" placeholder="Path" ref={(input) => {this.state.refs.s3_path = input; }} autoComplete="new-password" />
</NgIf> </NgIf>
<NgIf cond={this.should_appear('s3', 'endpoint')}>
<Input type={this.input_type('s3', 'endpoint')} name="endpoint" placeholder="Endpoint" ref={(input) => {this.state.refs.s3_endpoint = input; }} autoComplete="new-password" />
</NgIf>
</NgIf> </NgIf>
<Button type="submit" theme="emphasis">CONNECT</Button> <Button type="submit" theme="emphasis">CONNECT</Button>
</NgIf> </NgIf>

View File

@ -56,6 +56,7 @@ module.exports = {
// access_key_id: 'my_access_key', // access_key_id: 'my_access_key',
// secret_access_key: 'my_secret_key', // secret_access_key: 'my_secret_key',
// advanced: false, // advanced: false,
// endpoint: 'http://127.0.0.1:9000', // eg: your minio instance
// path: '/bucketname/' // path: '/bucketname/'
}, },
dropbox: {label: 'Dropbox'}, dropbox: {label: 'Dropbox'},

View File

@ -11,12 +11,18 @@ function decode(path){
} }
function connect(params){ function connect(params){
var s3 = new AWS.S3({ let config = {
apiVersion: '2006-03-01', apiVersion: '2006-03-01',
accessKeyId: params.access_key_id, accessKeyId: params.access_key_id,
secretAccessKey: params.secret_access_key, secretAccessKey: params.secret_access_key,
sslEnabled: true signatureVersion: 'v4',
}); s3ForcePathStyle: true,
//sslEnabled: true
};
if(params.endpoint){
config.endpoint = new AWS.Endpoint(params.endpoint);
}
var s3 = new AWS.S3(config);
return Promise.resolve(s3); return Promise.resolve(s3);
} }