aws-s3-cg-lib

1.1.5 • Public • Published

N|Solid

aws-s3-cg-lib

https://github.com/CloudGenUser/aws-s3-cg-lib

1. Introduction

This code has the objective to establish a connection with the AWS S3 bucket service and depending of the option selected (with the flag property) it will make a different operation in the AWS bucket.

The next are the possible flags and their corresponding actions:

  • Get the list of all buckets of the account.
  • Create a new bucket in the account.
  • Upload a file from a local machine to an specific S3 bucket in the account.
  • Get the list of files in a specific bucket.
  • Delete a specific bucket inside the account.
  • Get the content of a file that is inside a bucket(and split it into lines for large files).
  • Get the grant of a bucket.

Any other flag will be consider as an invalid values and will return an error message.

The purpose of this library is to handle S3 buckets in the AWS, getting information from the files in the bucket and other operations with the content of the bucket. Also, directories inside the bucket can be handled.

2. Library usage

The library can be installed from npm page with the next:

npm install aws-s3-cg-lib, npm i aws-s3-cg-lib or yarn install aws-s3-cg-lib

2.1. CREATETBUCKET

  • Arguments:
    • Required:
      • flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the CREATEBUKET is selected.
      • accessKey: It is the key to grant the access to the Amazon services.
      • secretKey: It is the password to access with the related key to the Amazon services.
      • region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/
      • bucketName: The name of the bucket in which is going to be performed the actions that includes the creation, deletion, to know grants, to search a file, to get the list of files or create the file.
      • section: Flag to define whether in the "GETFILE" process the file to be obtained will be taken by lines.
      • lines: Number of lines to split the file for the "GETFILE" process.
      • encoding: The encoding with which the file will be obtained in the "GETFILE" process.

The content and fileName properties are not required for this operation

  • Description: This request will create a new bucket inside the AWS S3 account.
  • Sample request:
{
	"flag":"CREATETBUCKET",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"bucketGrants"
}

Resultant sample:

{
	response: "Bucket created successfully at x location."
}

In case of some error the library will return the corresponding exception in the AWS S3 service.

2.2. DELETEBUCKET

  • Arguments:
    • Required:
      • flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the option DELETEBUCKET is selected.
      • accessKey: It is the key to grant the access to the Amazon services.
      • secretKey: It is the password to access with the related key to the Amazon services.
      • region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/
      • bucketName: The name of the bucket in which is going to be performed the actions that includes the creation, deletion, to know grants, to search a file, to get the list of files or create the file.

The content and fileName properties are not required for this operation

  • Description: This request is used to delete one of the buckets inside a AWS S3 account.
  • Sample request:
{
	"flag":"DELETEBUCKET",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"bucketGrants"
}

Resultant sample:

{
    response:"Bucket bucketTest was successfully removed."
}

In case of some error the library will return the corresponding exception in the AWS S3 service.

2.3. GETBUCKETGRANTS

  • Arguments:
    • Required:
      • flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the option GETBUCKETGRANTS is selected.
      • accessKey: It is the key to grant the access to the Amazon services.
      • secretKey: It is the password to access with the related key to the Amazon services.
      • region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/
      • bucketName: The name of the bucket in which is going to be performed the actions that includes the creation, deletion, to know grants, to search a file, to get the list of files or create the file.

The content and fileName properties are not required for this operation

  • Description: This request will show the grants related to the bucket in the AWS S3 account.
  • Sample request:
{
	"flag":"GETBUCKETGRANTS",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"bucketGrants"
}

Resultant sample:

{
    "grants": [
        {
            "Grantee": {
                "DisplayName": "displayName",
                "ID": "1234567890123456789012345678901234567890123456789012345678901234",
                "Type": "CanonicalUser"
            },
            "Permission": "FULL_CONTROL"
        }
    ]
}

In case of some error the library will return the corresponding exception in the AWS S3 service.

2.4. GETFILE

  • Arguments:
    • Required:
      • flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the option GETFILE is selected.
      • accessKey: It is the key to grant the access to the Amazon services.
      • secretKey: It is the password to access with the related key to the Amazon services.
      • region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/
      • bucketName: The name of the bucket in which is going to be performed the actions that includes the creation, deletion, to know grants, to search a file, to get the list of files or create the file.
      • fileName: The name of the file to get from the bucket.
    • No required
      • section: Flag to define whether in the "GETFILE" process the file to be obtained will be taken by lines.
      • lines: Number of lines to split the file for the "GETFILE" process.
      • encoding: The encoding with which the file will be obtained in the "GETFILE" process.

The content property is not required for this operation

  • Description: This request will get a file (the content) in a bucket inside the AWS S3 account.
  • Sample request:
{
	"flag":"GETFILE",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"scdf-cg-bucket",
	"fileName":"myFile.txt",
	"section":false,
    "lines":1,
    "encoding":"base64"
}

Resultant sample:

"Ww0KICAgIHsNCiAgICAibWFpbEZyb20iOiAibXltYWlsQG1haWwuY29tIiwgICAgIA0KICAgICJtYWlsUGVyc29uIjogIkpvbiBTbm93IiwgICAgIA0KICAgICJtYWlsVG8iOiAibWFpbC5kZXN0aW55QG1haWwuY29tIiwgDQogICAgIm1haWxDYyI6IG51bGwsDQogICAgIm1haWxCY2MiOiBudWxsLA0KICAgICJtYWlsU3ViamVjdCI6ICJQcnVlYmEgTWFpbCIsICAgICAgDQogICAgIm1haWxDb250ZW50IjogIlNhbHVkb3MiLA0KICAgICJjb250ZW50VHlwZSI6ICJ0ZXh0L3BsYWluIiwNCiAgICAiYXR0YWNobWVudHMiOiBudWxsLA0KICAgICJtYWlsQWNjb3VudCI6ICJzbXRwLW1haWwub3V0bG9vay5jb20sNTg3LG15bWFpbEBtYWlsLmNvbSxwQTU1dzByRCINCiAgICB9DQpd"
  • Section request:
{
	"flag":"GETFILE",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"scdf-cg-bucket",
	"fileName":"CSV150.csv",
	"section":true,
    "lines":50,
    "encoding":"base64"
}

Resultant sample:

[
    "SORT_KEY,PAYCODE,DATE_CLOCKEDIN,TIME_CLOCKEDIN,DATE_CLOCKEDOUT,TIMECLOCKED,TOTALMICLKTIME_AMT,TOTALAMT,EMP_FIRSTNAME,EMP_MIDDLENAME,EMP_LASTNAME,PAYPEREND_DATE,DLTSVNG_INDICATOR,STORECLOSE_TIME,EMPLOYEE_SSN,SEVENELEVEN_LOCATION,INCURREDNODE_LOCATION,CHRGNUMBER_LOCATION,PAYPROCESSCODE\r\n1001607,36590,02/27/22,06:08,02/27/22,14:08,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,TW,1001607,36590,36590\r\n1001607,36590,01/03/2022,09:54,01/03/2022,18:08,494,494,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1001607,36590,36590\r\n1001607,36590,02/03/2022,05:51,02/03/2022,14:07,496,496,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1001607,36590,36590\r\n1001607,36590,03/03/2022,11:54,03/03/2022,16:22,268,268,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1001607,36590,36590\r\n1002745,36575,02/25/22,07:00,02/25/22,17:00,600,600,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1002745,36575,36575\r\n1002745,36575,02/27/22,07:03,02/27/22,17:00,597,597,John,,Doe,03/03/2022,0,07:00,100 00 1234,VP,1002745,36575,36575\r\n1002745,36575,01/03/2022,07:00,01/03/2022,07:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,VP,1002745,36575,36575\r\n1002745,36575,02/03/2022,07:00,02/03/2022,07:00,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1002745,36575,36575\r\n1003100,36522,02/25/22,07:00,02/25/22,14:00,420,420,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1003100,36522,36522\r\n1003100,36522,02/27/22,09:00,02/27/22,16:00,420,420,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1003100,36522,36522\r\n1003100,36522,02/28/22,06:00,02/28/22,14:01,481,481,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1003100,36522,36522\r\n1003100,36522,01/03/2022,06:00,01/03/2022,14:00,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1003100,36522,36522\r\n1003100,36522,02/03/2022,06:00,02/03/2022,13:51,471,471,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1003100,36522,36522\r\n1003100,36522,03/03/2022,05:00,03/03/2022,05:01,1,1,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1003100,36522,36522\r\n1003686,36504,02/27/22,15:07,02/27/22,22:59,472,472,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1003686,36504,36504\r\n1003686,36504,02/28/22,15:00,02/28/22,01:07,607,607,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1003686,36504,36504\r\n1003686,36504,02/03/2022,15:07,02/03/2022,23:11,484,484,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1003686,36504,36504\r\n1003686,36504,03/03/2022,15:11,03/03/2022,22:23,432,432,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1003686,36504,36504\r\n1004296,40143,02/25/22,22:56,02/25/22,06:15,439,439,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1004296,40143,40143\r\n1004296,40143,02/26/22,13:50,02/26/22,22:17,507,507,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1004296,40143,40143\r\n1004296,40143,02/28/22,22:07,02/28/22,06:13,486,486,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1004296,40143,40143\r\n1004296,40143,01/03/2022,22:00,01/03/2022,06:21,501,501,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1004296,40143,40143\r\n1004296,40143,02/03/2022,21:55,02/03/2022,06:08,493,493,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1004296,40143,40143\r\n1004947,35096,02/26/22,09:54,02/26/22,13:57,243,243,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1004947,35096,35096\r\n1004947,35096,02/27/22,05:51,02/27/22,12:00,369,369,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1004947,35096,35096\r\n1004947,35096,02/03/2022,05:52,02/03/2022,12:00,368,368,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1004947,35096,35096\r\n1004947,35096,02/03/2022,15:55,02/03/2022,19:00,185,185,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1004947,35096,35096\r\n1005342,41928,02/26/22,05:55,02/26/22,13:20,445,445,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1005342,41928,41928\r\n1005342,41928,02/28/22,05:42,02/28/22,14:02,500,500,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1005342,41928,41928\r\n1005342,41928,01/03/2022,05:40,01/03/2022,13:28,468,468,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1005342,41928,41928\r\n1005342,41928,02/03/2022,06:01,02/03/2022,13:58,477,477,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,TW,1005342,41928,41928\r\n1005770,40879,01/03/2022,09:59,01/03/2022,15:09,310,310,John,,Doe,03/03/2022,0,07:00,100 00 1234,TW,1005770,40879,40879\r\n1005770,40879,02/03/2022,09:56,02/03/2022,11:03,67,67,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,TW,1005770,40879,40879\r\n1005770,40879,03/03/2022,11:02,03/03/2022,19:24,502,502,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1005770,40879,40879\r\n1006707,20560,02/26/22,10:46,02/26/22,19:03,497,497,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1006707,20560,20560\r\n1006707,20560,02/28/22,06:58,02/28/22,15:06,488,488,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1006707,20560,20560\r\n1006707,20560,01/03/2022,06:53,01/03/2022,15:03,490,490,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1006707,20560,20560\r\n1006707,20560,02/03/2022,06:53,02/03/2022,15:04,491,491,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1006707,20560,20560\r\n1006707,20560,04/03/2022,06:43,04/03/2022,08:21,98,98,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1006707,20560,20560\r\n1006909,36634,02/26/22,14:12,02/26/22,22:05,473,473,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1006909,36634,36634\r\n1006909,36634,02/27/22,14:09,02/27/22,22:40,511,511,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1006909,36634,36634\r\n1006909,36634,02/03/2022,16:16,02/03/2022,22:17,361,361,John,,Doe,03/03/2022,0,07:00,100 00 1234,VP,1006909,36634,36634\r\n1008256,36535,03/03/2022,07:00,03/03/2022,07:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,DF,1008256,36535,36535\r\n1008263,40201,02/25/22,07:00,02/25/22,07:00,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,DF,1008263,40201,40201\r\n1008263,40201,02/28/22,07:00,02/28/22,07:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1008263,40201,40201\r\n1008717,36535,02/25/22,09:59,02/25/22,14:14,255,255,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1008717,36535,36535\r\n1008717,36535,02/26/22,05:48,02/26/22,14:42,534,534,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1008717,36535,36535\r\n1008717,36535,02/27/22,05:57,02/27/22,14:04,487,487,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1008717,36535,36535\r\n1008717,36535,02/28/22,03:53,02/28/22,12:05,492,492,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1008717,36535,36535\r\n1008717,36535,03/03/2022,07:58,03/03/2022,12:18,260,260,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1008717,36535,36535",
    "SORT_KEY,PAYCODE,DATE_CLOCKEDIN,TIME_CLOCKEDIN,DATE_CLOCKEDOUT,TIMECLOCKED,TOTALMICLKTIME_AMT,TOTALAMT,EMP_FIRSTNAME,EMP_MIDDLENAME,EMP_LASTNAME,PAYPEREND_DATE,DLTSVNG_INDICATOR,STORECLOSE_TIME,EMPLOYEE_SSN,SEVENELEVEN_LOCATION,INCURREDNODE_LOCATION,CHRGNUMBER_LOCATION,PAYPROCESSCODE\r\n1008717,36535,04/03/2022,05:52,04/03/2022,07:00,68,68,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1008717,36535,36535\r\n1010973,36744,02/25/22,14:26,02/25/22,23:09,523,523,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1010973,36744,36744\r\n1010973,36744,02/26/22,14:53,02/26/22,23:00,487,487,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1010973,36744,36744\r\n1010973,36744,01/03/2022,14:53,01/03/2022,23:00,487,487,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1010973,36744,36744\r\n1010973,36744,02/03/2022,14:54,02/03/2022,23:11,497,497,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1010973,36744,36744\r\n1011005,36732,02/26/22,07:10,02/26/22,15:03,473,473,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1011005,36732,36732\r\n1011005,36732,02/27/22,06:14,02/27/22,15:05,531,531,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011005,36732,36732\r\n1011005,36732,03/03/2022,07:03,03/03/2022,15:07,484,484,John,,Doe,03/03/2022,0,07:00,100 00 1234,VP,1011005,36732,36732\r\n1011489,40560,02/25/22,07:00,02/25/22,07:00,240,240,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011489,40560,40560\r\n1011489,40560,02/27/22,14:00,02/27/22,23:00,540,540,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1011489,40560,40560\r\n1011489,40560,02/28/22,14:00,02/28/22,23:00,540,540,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011489,40560,40560\r\n1011489,40560,01/03/2022,14:00,01/03/2022,23:00,540,540,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1011489,40560,40560\r\n1011489,40560,02/03/2022,14:00,02/03/2022,23:00,540,540,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011489,40560,40560\r\n1011834,35400,02/26/22,06:03,02/26/22,06:05,2,2,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1011834,35400,35400\r\n1011834,35400,02/26/22,06:06,02/26/22,14:10,484,484,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011834,35400,35400\r\n1011834,35400,01/03/2022,06:08,01/03/2022,14:16,488,488,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1011834,35400,35400\r\n1011834,35400,02/03/2022,06:22,02/03/2022,14:00,458,458,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011834,35400,35400\r\n1011834,35400,03/03/2022,06:04,03/03/2022,14:07,483,483,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1011834,35400,35400\r\n1011834,35400,04/03/2022,06:04,04/03/2022,07:19,75,75,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1011834,35400,35400\r\n1012362,36510,02/25/22,23:53,02/25/22,05:57,364,364,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1012362,36510,36510\r\n1012362,36510,02/26/22,23:50,02/26/22,06:05,375,375,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1012362,36510,36510\r\n1012362,36510,02/27/22,23:58,02/27/22,05:50,352,352,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1012362,36510,36510\r\n1012362,36510,02/28/22,23:56,02/28/22,05:58,362,362,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1012362,36510,36510\r\n1012362,36510,03/03/2022,23:46,03/03/2022,05:58,372,372,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1012362,36510,36510\r\n1012622,25608,02/27/22,16:01,02/27/22,22:01,360,360,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1012622,25608,25608\r\n1012622,25608,02/28/22,15:47,02/28/22,22:11,384,384,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1012622,25608,25608\r\n1012622,25608,01/03/2022,15:38,01/03/2022,22:15,397,397,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1012622,25608,25608\r\n1012622,25608,02/03/2022,15:36,02/03/2022,22:34,418,418,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1012622,25608,25608\r\n1012622,25608,03/03/2022,08:37,03/03/2022,12:51,254,254,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1012622,25608,25608\r\n1012622,25608,03/03/2022,15:38,03/03/2022,22:21,403,403,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1012622,25608,25608\r\n1014019,21882,02/25/22,22:06,02/25/22,05:06,420,420,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014019,21882,21882\r\n1014019,21882,02/26/22,22:11,02/26/22,06:24,493,493,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1014019,21882,21882\r\n1014019,21882,01/03/2022,13:53,01/03/2022,22:22,509,509,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014019,21882,21882\r\n1014019,21882,02/03/2022,13:53,02/03/2022,22:14,501,501,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1014019,21882,21882\r\n1014019,21882,03/03/2022,13:38,03/03/2022,22:15,517,517,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014019,21882,21882\r\n1014401,36510,02/25/22,08:18,02/25/22,11:16,178,178,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1014401,36510,36510\r\n1014401,36510,02/25/22,11:16,02/25/22,14:53,217,217,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014401,36510,36510\r\n1014401,36510,02/27/22,08:46,02/27/22,11:33,167,167,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1014401,36510,36510\r\n1014401,36510,01/03/2022,08:18,01/03/2022,15:01,403,403,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014401,36510,36510\r\n1014401,36510,02/03/2022,07:18,02/03/2022,15:01,463,463,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1014401,36510,36510\r\n1014624,40239,02/26/22,13:53,02/26/22,22:16,503,503,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014624,40239,40239\r\n1014624,40239,02/27/22,14:04,02/27/22,22:14,490,490,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1014624,40239,40239\r\n1014624,40239,03/03/2022,13:59,03/03/2022,22:09,490,490,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1014624,40239,40239\r\n1016178,25596,02/27/22,22:00,02/27/22,05:00,420,420,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1016178,25596,25596\r\n1016178,25596,02/03/2022,17:00,02/03/2022,22:00,300,300,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1016178,25596,25596\r\n1016229,19235,02/26/22,07:05,02/26/22,12:37,332,332,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1016229,19235,19235\r\n1016229,19235,02/27/22,11:47,02/27/22,17:07,320,320,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1016229,19235,19235\r\n1016229,19235,02/28/22,11:59,02/28/22,17:06,307,307,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1016229,19235,19235\r\n1016229,19235,01/03/2022,07:03,01/03/2022,12:30,327,327,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1016229,19235,19235\r\n1016229,19235,02/03/2022,07:36,02/03/2022,07:36,1440,1440,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1016229,19235,19235",
    "SORT_KEY,PAYCODE,DATE_CLOCKEDIN,TIME_CLOCKEDIN,DATE_CLOCKEDOUT,TIMECLOCKED,TOTALMICLKTIME_AMT,TOTALAMT,EMP_FIRSTNAME,EMP_MIDDLENAME,EMP_LASTNAME,PAYPEREND_DATE,DLTSVNG_INDICATOR,STORECLOSE_TIME,EMPLOYEE_SSN,SEVENELEVEN_LOCATION,INCURREDNODE_LOCATION,CHRGNUMBER_LOCATION,PAYPROCESSCODE\r\n1016792,20925,02/26/22,06:46,02/26/22,15:20,514,514,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1016792,20925,20925\r\n1016792,20925,02/28/22,06:47,02/28/22,15:05,498,498,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1016792,20925,20925\r\n1016792,20925,01/03/2022,06:52,01/03/2022,15:14,502,502,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1016792,20925,20925\r\n1016792,20925,02/03/2022,06:49,02/03/2022,15:14,505,505,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1016792,20925,20925\r\n1016792,20925,04/03/2022,06:54,04/03/2022,14:29,455,455,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1016792,20925,20925\r\n1017090,35922,02/26/22,12:02,02/26/22,17:00,298,298,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017090,35922,35922\r\n1017090,35922,02/27/22,12:35,02/27/22,17:04,269,269,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017090,35922,35922\r\n1017090,35922,02/28/22,23:03,02/28/22,07:00,477,477,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017090,35922,35922\r\n1017090,35922,02/03/2022,11:09,02/03/2022,17:00,351,351,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017090,35922,35922\r\n1017090,35922,03/03/2022,16:00,03/03/2022,23:00,420,420,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017090,35922,35922\r\n1017090,35922,04/03/2022,03:30,04/03/2022,05:00,90,90,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017090,35922,35922\r\n1017970,35559,02/25/22,07:00,02/25/22,16:00,540,540,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017970,35559,35559\r\n1017970,35559,02/26/22,07:00,02/26/22,15:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017970,35559,35559\r\n1017970,35559,02/27/22,07:00,02/27/22,23:00,960,960,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017970,35559,35559\r\n1017970,35559,01/03/2022,07:00,01/03/2022,15:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017970,35559,35559\r\n1017970,35559,03/03/2022,07:00,03/03/2022,15:00,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017970,35559,35559\r\n1017996,36819,02/25/22,10:56,02/25/22,19:01,485,485,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017996,36819,36819\r\n1017996,36819,02/26/22,07:02,02/26/22,15:06,484,484,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017996,36819,36819\r\n1017996,36819,02/27/22,07:52,02/27/22,15:01,429,429,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017996,36819,36819\r\n1017996,36819,02/03/2022,22:49,02/03/2022,06:14,445,445,John,,Doe,03/03/2022,0,07:00,100 00 1234,TD,1017996,36819,36819\r\n1017996,36819,03/03/2022,22:00,03/03/2022,06:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017996,36819,36819\r\n1017999,36840,02/25/22,09:58,02/25/22,17:54,476,476,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017999,36840,36840\r\n1017999,36840,02/26/22,09:59,02/26/22,17:57,478,478,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017999,36840,36840\r\n1017999,36840,02/28/22,08:00,02/28/22,16:13,493,493,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017999,36840,36840\r\n1017999,36841,02/03/2022,17:36,02/03/2022,22:35,299,299,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1017999,36841,36841\r\n1017999,36840,03/03/2022,10:00,03/03/2022,18:02,482,482,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1017999,36840,36840\r\n1018022,36841,02/25/22,23:01,02/25/22,07:04,483,483,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018022,36841,36841\r\n1018022,36841,02/26/22,22:57,02/26/22,07:17,500,500,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018022,36841,36841\r\n1018022,36841,02/27/22,23:03,02/27/22,07:00,477,477,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018022,36841,36841\r\n1018022,36841,02/03/2022,02:59,02/03/2022,10:35,456,456,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018022,36841,36841\r\n1018022,36841,02/03/2022,23:02,02/03/2022,07:09,487,487,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,VP,1018022,36841,36841\r\n1018057,36855,02/27/22,07:00,02/27/22,07:00,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,VP,1018057,36855,36855\r\n1018057,36855,02/28/22,07:00,02/28/22,07:00,480,480,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018057,36855,36855\r\n1018057,36855,01/03/2022,22:00,01/03/2022,06:00,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018057,36855,36855\r\n1018057,36855,02/03/2022,22:17,02/03/2022,06:15,478,478,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018057,36855,36855\r\n1018057,36855,03/03/2022,22:16,03/03/2022,06:14,478,478,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018057,36855,36855\r\n1018135,36856,02/25/22,17:12,02/25/22,00:46,454,454,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018135,36856,36856\r\n1018135,36856,02/26/22,16:17,02/26/22,00:10,473,473,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018135,36856,36856\r\n1018135,36856,02/27/22,14:52,02/27/22,00:05,553,553,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018135,36856,36856\r\n1018135,36856,02/03/2022,17:40,02/03/2022,00:11,391,391,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018135,36856,36856\r\n1018135,36856,03/03/2022,16:28,03/03/2022,00:13,465,465,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018135,36856,36856\r\n1018138,36832,02/28/22,05:54,02/28/22,14:05,491,491,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018138,36832,36832\r\n1018138,36832,01/03/2022,05:57,01/03/2022,14:04,487,487,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018138,36832,36832\r\n1018138,36832,02/03/2022,10:02,02/03/2022,14:11,249,249,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018138,36832,36832\r\n1018138,36832,03/03/2022,05:57,03/03/2022,14:02,485,485,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018138,36832,36832\r\n1018402,40772,02/26/22,23:01,02/26/22,07:28,507,507,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018402,40772,40772\r\n1018402,40772,02/28/22,10:20,02/28/22,18:10,470,470,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018402,40772,40772\r\n1018402,40772,01/03/2022,15:54,01/03/2022,00:32,518,518,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018402,40772,40772\r\n1018402,40772,02/03/2022,15:00,02/03/2022,23:25,505,505,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018402,40772,40772\r\n1018402,40772,03/03/2022,15:51,03/03/2022,23:24,453,453,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018402,40772,40772",
    "SORT_KEY,PAYCODE,DATE_CLOCKEDIN,TIME_CLOCKEDIN,DATE_CLOCKEDOUT,TIMECLOCKED,TOTALMICLKTIME_AMT,TOTALAMT,EMP_FIRSTNAME,EMP_MIDDLENAME,EMP_LASTNAME,PAYPEREND_DATE,DLTSVNG_INDICATOR,STORECLOSE_TIME,EMPLOYEE_SSN,SEVENELEVEN_LOCATION,INCURREDNODE_LOCATION,CHRGNUMBER_LOCATION,PAYPROCESSCODE\r\n1018414,35929,02/25/22,08:09,02/25/22,14:43,394,394,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018414,35929,35929\r\n1018414,35929,02/28/22,07:06,02/28/22,15:26,500,500,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018414,35929,35929\r\n1018414,35929,01/03/2022,07:11,01/03/2022,13:19,368,368,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018414,35929,35929\r\n1018414,35929,02/03/2022,07:07,02/03/2022,15:07,480,480,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1018414,35929,35929\r\n1018414,35929,03/03/2022,07:04,03/03/2022,14:05,421,421,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1018414,35929,35929\r\n1020248,40559,02/25/22,09:06,02/25/22,11:17,131,131,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1020248,40559,40559\r\n1020248,40559,02/26/22,05:06,02/26/22,11:52,406,406,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1020248,40559,40559\r\n1020248,40559,02/27/22,05:22,02/27/22,12:50,448,448,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1020248,40559,40559\r\n1020248,40559,02/28/22,05:43,02/28/22,11:02,319,319,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1020248,40559,40559\r\n1020248,40559,04/03/2022,03:28,04/03/2022,06:59,211,211,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1020248,40559,40559\r\n1020486,39721,02/25/22,14:50,02/25/22,21:54,424,424,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1020486,39721,39721\r\n1020486,39721,02/27/22,14:00,02/27/22,19:00,300,300,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1020486,39721,39721\r\n1020486,39721,02/28/22,14:14,02/28/22,22:00,466,466,Jane,,Doe,03/03/2022,0,07:00,100 00 4321,RR,1020486,39721,39721\r\n1021063,35553,02/25/22,07:12,02/25/22,11:32,260,260,John,,Doe,03/03/2022,0,07:00,100 00 1234,RR,1021063,35553,35553"
]

In case of some error the library will return the corresponding exception in the AWS S3 service.

2.5. GETLISTBUCKETS

  • Arguments:
    • Required:
      • flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the option GETLISTBUCKETS is selected.
      • accessKey: It is the key to grant the access to the Amazon services.
      • secretKey: It is the password to access with the related key to the Amazon services.
      • region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/

The content, bucket and fileName properties are not required for this operation

  • Description: This request will get a JSON with a list of all the buckets inside the AWS S3 account.
  • Sample request:
{
	"flag":"GETLISTBUCKETS",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING"
}

Resultant sample:

{
    "response": [
        {
            "Name": "bucket1",
            "CreationDate": "2022-01-01T10:10:10.000Z"
        },
        {
            "Name": "bucket2",
            "CreationDate": "2022-01-01T10:10:10.000Z"
        }
    ]
}

In case of some error the library will return the corresponding exception in the AWS S3 service.

2.6. GETLISTFILESINBUCKET

  • Arguments:
    • Required:
      • flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the option GETLISTFILESINBUCKET is selected.
      • accessKey: It is the key to grant the access to the Amazon services.
      • secretKey: It is the password to access with the related key to the Amazon services.
      • region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/
      • bucketName: The name of the bucket in which is going to be performed the actions that includes the creation, deletion, to know grants, to search a file, to get the list of files or create the file.

The content and fileName properties are not required for this operation

  • Description: This request will get a JSON with a list of all the files inside a bucket in the AWS S3 account.
  • Sample request:
{
	"flag":"GETLISTFILESINBUCKET",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"bucketTest"
}

Resultant sample:

{
    "response": {
        "IsTruncated": false,
        "Marker": "",
        "Contents": [
            {
                "Key": "testFile.txt",
                "LastModified": "2022-01-01T10:10:22.000Z",
                "ETag": "\"e8d78389ed292fbbe91153exb8e0bae4-9\"",
                "ChecksumAlgorithm": [],
                "Size": 78858823,
                "StorageClass": "STANDARD",
                "Owner": {
                    "DisplayName": "xrnadmin_us",
                    "ID": "efdba54569b1468058a276bcd4b0f662b728f4a9401186dda9357d949e123456"
                }
            },
            {
                "Key": "buckets-s3/",
                "LastModified": "2022-01-01T10:10:22.000Z",
                "ETag": "\"d41d8cd98f00b204e9812345acf8427e\"",
                "ChecksumAlgorithm": [],
                "Size": 0,
                "StorageClass": "STANDARD",
                "Owner": {
                    "DisplayName": "xraadmin_us",
                    "ID": "efdba14219b4546789a276bcd4b0f662b728f4a9401186dda9357d949e179520"
                }
            }
        ],
        "Name": "listBucket",
        "Prefix": "",
        "MaxKeys": 1000,
        "CommonPrefixes": []
    }
}

In case of some error the library will return the corresponding exception in the AWS S3 service.

2.7. UPLOADFILE

  • Arguments: - flag: The string that contains the action to be executed, one of the next options can be selected: CREATETBUCKET, DELETEBUCKET, GETBUCKETGRANTS, GETFILE, GETLISTBUCKETS, GETLISTFILESINBUCKET, UPLOADFILE. The string is not case sensitive. In this case the option UPLOADFILE is selected. - accessKey: It is the key to grant the access to the Amazon services. - secretKey: It is the password to access with the related key to the Amazon services. - region: It is a code that corresponds to the zone of the services in wich the Amazon services are alocated according with the user contract to use the AWS services, the list of codes and what is the neares code in user zone can be reviewed in the next link: https://aws.amazon.com/es/about-aws/global-infrastructure/regions_az/ - bucketName: The name of the bucket in which is going to be performed the actions that includes the creation, deletion, to know grants, to search a file, to get the list of files or create the file. - content: It corresponds to the content of a file when the option to create a file is selected. - fileName: The name of the file to be created.

  • Description: This request will create a copy of a file inside a specific bucket in the AWS S3 account.

  • Sample request:

{
	"flag":"GETLISTFILESINBUCKET",
	"region":"us-east-1",
	"accessKey":"ACCESSKEYSTRING",
	"secretKey":"SECRETKEYSTRING",
	"bucketName":"bucketTest",
	"content": "Hello World.",
	"fileName": "myFile.txt"
}

Resultant sample:

{
    response:"File myFile.txt was successfully uploaded in bucketTest."
}

In case of some error the library will return the corresponding exception in the AWS S3 service.

Package Sidebar

Install

npm i aws-s3-cg-lib

Weekly Downloads

4

Version

1.1.5

License

ISC

Unpacked Size

46.3 kB

Total Files

6

Last publish

Collaborators

  • cloudgenuser