@@ -861,42 +861,37 @@ s3Client.removeBucketEncryption('my-bucketname', function (err) {
861861
862862<a name =" getObject " ></a >
863863
864- ### getObject(bucketName, objectName, getOpts[ , callback ] )
864+ ### getObject(bucketName, objectName, getOpts)
865865
866866Downloads an object as a stream.
867867
868868** Parameters**
869869
870- | Param | Type | Description |
871- | ----------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
872- | ` bucketName ` | _ string_ | Name of the bucket. |
873- | ` objectName ` | _ string_ | Name of the object. |
874- | ` getOpts ` | _ object_ | Version of the object in the form ` {versionId:"my-versionId"} ` . Default is ` {} ` . (optional) |
875- | ` callback(err, stream) ` | _ function_ | Callback is called with ` err ` in case of error. ` stream ` is the object content stream. If no callback is passed, a ` Promise ` is returned. |
870+ | Param | Type | Description |
871+ | ------------ | -------- | ------------------------------------------------------------------------------------------- |
872+ | ` bucketName ` | _ string_ | Name of the bucket. |
873+ | ` objectName ` | _ string_ | Name of the object. |
874+ | ` getOpts ` | _ object_ | Version of the object in the form ` {versionId:"my-versionId"} ` . Default is ` {} ` . (optional) |
876875
877876** Return Value**
878877
879- | Param | Type | Description |
880- | -------- | -------- | ----------------------------------- |
881- | ` stream ` | _ Stream _ | Stream emitting the object content. |
878+ | Param | Type | Description |
879+ | -------- | ----------------- | ----------------------------------- |
880+ | ` stream ` | ` stream.Readable ` | Stream emitting the object content. |
882881
883882** Example**
884883
885884``` js
886885let size = 0
887- minioClient .getObject (' mybucket' , ' photo.jpg' , function (err , dataStream ) {
888- if (err) {
889- return console .log (err)
890- }
891- dataStream .on (' data' , function (chunk ) {
892- size += chunk .length
893- })
894- dataStream .on (' end' , function () {
895- console .log (' End. Total size = ' + size)
896- })
897- dataStream .on (' error' , function (err ) {
898- console .log (err)
899- })
886+ const dataStream = await minioClient .getObject (' mybucket' , ' photo.jpg' )
887+ dataStream .on (' data' , function (chunk ) {
888+ size += chunk .length
889+ })
890+ dataStream .on (' end' , function () {
891+ console .log (' End. Total size = ' + size)
892+ })
893+ dataStream .on (' error' , function (err ) {
894+ console .log (err)
900895})
901896```
902897
@@ -906,19 +901,15 @@ Get a specific object version.
906901
907902``` js
908903let size = 0
909- minioClient .getObject (' mybucket' , ' photo.jpg' , { versionId: ' my-versionId' }, function (err , dataStream ) {
910- if (err) {
911- return console .log (err)
912- }
913- dataStream .on (' data' , function (chunk ) {
914- size += chunk .length
915- })
916- dataStream .on (' end' , function () {
917- console .log (' End. Total size = ' + size)
918- })
919- dataStream .on (' error' , function (err ) {
920- console .log (err)
921- })
904+ const dataStream = await minioClient .getObject (' mybucket' , ' photo.jpg' , { versionId: ' my-versionId' })
905+ dataStream .on (' data' , function (chunk ) {
906+ size += chunk .length
907+ })
908+ dataStream .on (' end' , function () {
909+ console .log (' End. Total size = ' + size)
910+ })
911+ dataStream .on (' error' , function (err ) {
912+ console .log (err)
922913})
923914```
924915
@@ -950,19 +941,15 @@ Downloads the specified range bytes of an object as a stream.
950941``` js
951942let size = 0
952943// reads 30 bytes from the offset 10.
953- minioClient .getPartialObject (' mybucket' , ' photo.jpg' , 10 , 30 , function (err , dataStream ) {
954- if (err) {
955- return console .log (err)
956- }
957- dataStream .on (' data' , function (chunk ) {
958- size += chunk .length
959- })
960- dataStream .on (' end' , function () {
961- console .log (' End. Total size = ' + size)
962- })
963- dataStream .on (' error' , function (err ) {
964- console .log (err)
965- })
944+ const dataStream = await minioClient .getPartialObject (' mybucket' , ' photo.jpg' , 10 , 30 )
945+ dataStream .on (' data' , function (chunk ) {
946+ size += chunk .length
947+ })
948+ dataStream .on (' end' , function () {
949+ console .log (' End. Total size = ' + size)
950+ })
951+ dataStream .on (' error' , function (err ) {
952+ console .log (err)
966953})
967954```
968955
@@ -972,27 +959,16 @@ To get a specific version of an object
972959``` js
973960const versionedObjSize = 0
974961// reads 30 bytes from the offset 10.
975- minioClient .getPartialObject (
976- ' mybucket' ,
977- ' photo.jpg' ,
978- 10 ,
979- 30 ,
980- { versionId: ' my-versionId' },
981- function (err , dataStream ) {
982- if (err) {
983- return console .log (err)
984- }
985- dataStream .on (' data' , function (chunk ) {
986- versionedObjSize += chunk .length
987- })
988- dataStream .on (' end' , function () {
989- console .log (' End. Total size = ' + versionedObjSize)
990- })
991- dataStream .on (' error' , function (err ) {
992- console .log (err)
993- })
994- },
995- )
962+ const dataStream = await minioClient .getPartialObject (' mybucket' , ' photo.jpg' , 10 , 30 , { versionId: ' my-versionId' })
963+ dataStream .on (' data' , function (chunk ) {
964+ versionedObjSize += chunk .length
965+ })
966+ dataStream .on (' end' , function () {
967+ console .log (' End. Total size = ' + versionedObjSize)
968+ })
969+ dataStream .on (' error' , function (err ) {
970+ console .log (err)
971+ })
996972```
997973
998974<a name =" fGetObject " ></a >
@@ -1981,26 +1957,23 @@ listener.on('notification', function (record) {
19811957
19821958<a name =" getBucketPolicy " ></a >
19831959
1984- ### getBucketPolicy(bucketName [ , callback ] )
1960+ ### async getBucketPolicy(bucketName: string): Promise< string >
19851961
19861962Get the bucket policy associated with the specified bucket. If ` objectPrefix `
19871963is not empty, the bucket policy will be filtered based on object permissions
19881964as well.
19891965
19901966** Parameters**
19911967
1992- | Param | Type | Description |
1993- | ----------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1994- | ` bucketName ` | _ string_ | Name of the bucket |
1995- | ` callback(err, policy) ` | _ function_ | Callback function is called with non ` null ` err value in case of error. ` policy ` is [ bucket policy] ( https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html ) . If no callback is passed, a ` Promise ` is returned. |
1968+ | Param | Type | Description |
1969+ | ------------ | -------- | ------------------ |
1970+ | ` bucketName ` | _ string_ | Name of the bucket |
19961971
19971972``` js
19981973// Retrieve bucket policy of 'my-bucketname'
1999- minioClient .getBucketPolicy (' my-bucketname' , function (err , policy ) {
2000- if (err) throw err
1974+ const policy = await minioClient .getBucketPolicy (' my-bucketname' )
20011975
2002- console .log (` Bucket policy file: ${ policy} ` )
2003- })
1976+ console .log (` Bucket policy file: ${ policy} ` )
20041977```
20051978
20061979<a name =" setBucketPolicy " ></a >
0 commit comments