Every line of 'aws s3 listobjectsv2' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
51 async function testList(s3, params) { 52 /* eslint-disable-next-line no-unused-vars */ 53 const { Key, ...callParams } = { ...params, ...{ Prefix: params.Key } }; 54 55 try { 56 await s3.listObjectsV2(callParams).promise(); 57 return true; 58 } 59 catch (error) { 60 return false; 61 } 62 }
400 async function listS3ObjectsV2(params) { 401 // Fetch the first list of objects from S3 402 let listObjectsResponse = await awsServices.s3().listObjectsV2(params).promise(); 403 let discoveredObjects = listObjectsResponse.Contents; 404 405 // Keep listing more objects from S3 until we have all of them 406 while (listObjectsResponse.IsTruncated) { 407 listObjectsResponse = await awsServices.s3().listObjectsV2( // eslint-disable-line no-await-in-loop, max-len 408 // Update the params with a Continuation Token 409 Object.assign( 410 {}, 411 params, 412 { ContinuationToken: listObjectsResponse.NextContinuationToken } 413 ) 414 ).promise(); 415 discoveredObjects = discoveredObjects.concat(listObjectsResponse.Contents); 416 } 417 418 return discoveredObjects; 419 }
121 async list(iteratee: Function) { 122 123 let nextMarker = null; 124 do { 125 126 const params = this._paramsProvider.getListObjectsParams(this._options); 127 params.Marker = nextMarker; 128 129 let data; 130 try { 131 data = await this._s3.listObjectsAsync(params); 132 } catch (error) { 133 throw new S3Error(error); 134 } 135 136 for (const content of data.Contents) { 137 const file = this::listItemToFile(content); 138 139 // Iteratee may exit iteration early by explicitly returning false 140 if (await iteratee(file) === false) { 141 return; 142 } 143 } 144 145 nextMarker = data.IsTruncated 146 ? data.NextMarker || lodash.chain(data.Contents).last().get("Key").value() 147 : null; 148 149 } while (nextMarker); 150 }
58 list() { 59 const deferred = Q.defer(); 60 let ids = []; 61 const params = { 62 Bucket: this.bucket, 63 MaxKeys: 2000 64 }; 65 const callback = (err, data) => { 66 if (err) return deferred.reject(err); 67 68 ids = ids.concat(data.Contents.map(data => data.Key)); 69 70 if (data.IsTruncated) { 71 params.ContinuationToken = data.NextContinuationToken; 72 this.client.listObjectsV2(params, callback); 73 } else { 74 deferred.resolve(ids); 75 } 76 }; 77 78 this.client.listObjectsV2(params, callback); 79 80 return deferred.promise; 81 }
43 export function getObject (s3, params) { 44 return s3.getObject(params).promise(); 45 };