NEQTO Docs
  • Languages iconEnglish
    • 日本語
  • Docs
  • API
  • FAQ

›Integration

Getting Started

  • NEQTO Hello World!
  • Tutorial Step 1. NEQTO Console Setting
  • Tutorial Step 2. Device Settings & Launching Service (NEQTO Bridge)
  • Tutorial Step 2. Device Settings & Launching Service (STM32 Discovery)
  • Tutorial Step 2. Device Settings & Launching Service (SPRESENSE)
  • Tutorial Step 3. Application development using scripts

NEQTO

  • NEQTO Account Registration
  • Sub-accounts
  • API Usage
  • NEQTO Engine Firmware List
  • Support Guidelines
  • For safe and secure use of the NEQTO products
  • Vulnerability Disclosure Policy

NEQTO Console

  • Introduction
  • Fundamentals
  • Administrative Actions
  • Device Management
  • Linux-based Device Management
  • Batch Registration
  • Scripts
  • Actions and Contacts
  • View Data from the Console
  • NEQTO Apps

    • About NEQTO Apps
    • NEQTO Infinitypool
    • NEQTO Insights
    • NEQTO Custodia
    • NEQTO Flow
  • Machine Driver
  • Recommended Browsers
  • Billing Information

SPRESENSE

    Hardware Specifications

    • 01. About Spresense

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. Spresense Wi-Fi Initial Setup
    • 04. Spresense LTE-M Initial Setup
    • 05. Debug Log Acquisition
    • 06. System LED Indications
    • 07. Event Messages
    • 08. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. GPIO
    • 12. UART
    • 13. SPI
    • 14. I2C
    • 15. ADC
    • 16. GNSS
    • 17. Camera
    • 18. Utils
    • 19. nqSpresense
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte

STM32 Discovery

    Hardware Specifications

    • 01. About STM32 Discovery Kit (B-L4S5I-IOT01A)

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. STM32 Discovery Wi-Fi Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 18. Utils
    • 19. nqDiscovery
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi

NEQTO Bridge

    Hardware Specifications

    • 01. NEQTO Bridge Module
    • 02. NEQTO Bridge Wi-Fi Module
    • 03. NEQTO Bridge LTE-1 Module
    • 04. NEQTO Bridge LTE-M/NB Module
    • 05. NEQTO Bridge IO Board
    • 06. NEQTO Bridge Digital IO Board
    • 07. NEQTO Bridge Connector Board

    Software Specifications

    • 01. Operational Flow
    • 02. NEQTO Bridge Wi-Fi Module Initial Setup
    • 03. NEQTO Bridge LTE Module Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 17. BLE
    • 18. Utils
    • 19. nqBridge
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte
    • 25. nqLAN
    • 26. nqEx

Linux-based device

    Software Specifications

    • 01. System Requirements
    • 02. Installation
    • 03. Software Configurations
    • 04. Operational Flow
    • 05. Debug Log Acquisition
    • 06. Event Messages
    • 07. Updating Software

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. RTC
    • 10. UNIXSocket
    • 11. FileSystem
    • 12. SubProcess
    • 13. SubTask
    • 14. Queue
    • 15. Utils
    • 16. nqLinux
    • 17. nqService
    • 18. nqMqtt
    • 19. nqFOTA
    • 20. nqLAN

neqto.js Libraries

  • About neqto.js Libraries
  • UART

    • GM65 Barcode Reader
    • SRF Ultrasonic Range Finder - Serial Mode

    I2C

    • HTS221 v2 Temperature and Humidity Sensor
    • LIS2DW12 v2 Accelerometer
    • SRF Ultrasonic Range Finder - I2C Mode
    • [Archive] HTS221 Temperature and Humidity Sensor
    • [Archive] LIS2DW12 Accelerometer

    Utils

    • RTC Alarm Synchronized Scheduler

    Integration

    • AWS S3 v2
    • AWS IoT Core v2
    • Azure IoT v2
    • [Archive] GCP IoT Core
    • [Archive] AWS S3
    • [Archive] AWS IoT Core

neqto.js Snippets

  • About neqto.js Snippets
  • DataDog
  • Dropbox
  • Google Sheets
  • InfluxDB
  • Oracle Cloud Object Storage
  • Salesforce
  • Splunk
  • Niagara
  • [Archive] SAP Cloud Platform Internet of Things

Release Notes

  • NEQTO Console Updates
  • NEQTO Firmware (Bridge Wi-Fi/LTE Module) Releases
  • NEQTO Firmware (STM32 Discovery Wi-Fi) Releases
  • NEQTO Firmware (Spresense Wi-Fi/LTE-M) Releases
  • NEQTO Engine for Linux Releases
  • neqto.js Libraries Releases

AWS S3 v2

This library is a built-in class that provides functions to communicate with Amazon Simple Storage Service (Amazon S3).

Library usage requirements
Type Integrations
Name AWS_S3_V2
Version 2.1.0
Code size used 10.2KB
Resources used HTTPS x 1, Timers x 1

Related Documents

  • For detailed specifications regarding AWS S3, please refer to the "Amazon Simple Storage Service Documentation".
  • Specification of the HTTPS object (NEQTO Bridge/STM32 Discovery/SPRESENSE/Linux)



Abstracts

Methods()/PropertiesSummaryNote
new AWS_S3()Creates an AWS_S3 instance.

{AWS_S3} Instance

Method()/PropertySummaryNote
.createXAmzHeaders()Creates HTTP headers from a parameter list with HTTP request parameter names in the AWS API style.
.createHttpHeader()Creates an authentication header for the AWS Signature v4 specification.
.put()Sends data to the S3 bucket with a PUT request.
.get()Gets data from the S3 bucket with a GET request.
.abortRequest()Aborts the currently ongoing HTTP request.
.errorsArray of {Error} objects containing invalid key names (strings)
Generated when an invalid parameter is detected in the constructor or .setConfig().
.CONST.VERSIONVersion (string)v2.1.0+



Details

new AWS_S3([config])

Creates an AWS_S3 instance.

NameTypeM/ODescriptionNote
configObjectoptionalConfiguration
Refer to config for details.
return{AWS_S3}-{AWS_S3} : Generated {AWS_S3}If invalid parameters are detected, .errors will be generated.

config

NameTypeM/ODescriptionNote
regionstringmandatoryRegion to be used when accessing the S3 bucket
accessKeyIdstringmandatoryIAM access key ID
secretKeystringmandatoryIAM secret access key
bucketstringmandatoryS3 bucket name
castringmandatoryRoot CA certificate for AWS S3
Specify a string in PEM format. Use \n for line feed code.
httpTimeoutnumberoptionalHTTP request timeout value [s]
If 0, the timeout function is disabled.
The default value is 0.
v2.1.0+
timeoutnumber-This parameter is ignored.Unused

Set the Configuration (config) when creating an AWS_S3 instance.
If an invalid parameter is detected, an array of {Error} objects containing the invalid key name is generated as the .errors property. If the parameters are successful, the .errors property will be deleted.

var s3 = new AWS_S3({
    region: <value>,
    accessKeyId: <value>,
    secretKey: <value>,
    bucket: <value>,
    ca: <value>
});
if('errors' in s3) {
    //TODO: Handle errors
}

{Error}

NameTypeDescriptionNote
.namestringInvalid key name
.messagestringError Messages

.setConfig(config)

Set the Configuration (config) after the AWS_S3 instance is created.
If an invalid parameter is detected, an array of {Error} objects containing the invalid key name is generated as the .errors property. If the parameters are successful, the .errors property will be deleted.

var s3 = new AWS_S3();
s3.setConfig({
    region: <value>,
    accessKeyId: <value>,
    secretKey: <value>,
    bucket: <value>,
    ca: <value>
});
if('errors' in s3) {
    //TODO: Handle errors
}

Setter Methods

After the AWS_S3 instance is created, Configuration (config) can be set individually using the following setter methods.
If successful, the own instance is returned. If an invalid parameter is detected, {Error} is returned.

Setter MethodDescriptionNote
.setRegion(value)Sets the region.
.setAccessKeyId(value)Sets the accessKeyId.
.setSecretKey(value)Sets the secretKey.
.setBucket(value)Sets the bucket.
.setRootCA(value)Sets the ca.
.setHttpTimeout(value)Sets the httpTimeout.v2.1.0+
.setRequestTimeout(value)Sets the timeout.Unused

.createXAmzHeaders(params)

Creates HTTP headers from a parameter list with HTTP request parameter names in the AWS API style.

The following request parameters are supported by this method.

  • AWS API - PutObject
  • AWS API - GetObject  (v2.1.0+)

If any other request parameter name is specified, it will be inherited by the HTTP headers generated without conversion.
Note that bucket and key cannot be used as request parameter names. They will be ignored.

NameTypeM/ODescriptionNote
paramsobjectmandatoryParameter list
returnobject-HTTP header

The following is an example of usage:

var params = {
    //<RequestPatameterName>: <value> 
    "Tagging": "example=tag",
    "ACL": "bucket-owner-full-control",
    "ContentLength": 256
};

//Request parameter names are converted to HTTP headers
var headers = s3.createXAmzHeaders(params);

print(JSON.stringify(headers));
//{"x-amz-tagging":"example=tag","x-amz-acl":"bucket-owner-full-control","Content-Length":256}

.createHttpHeader(host,path,method[,bodyToHash[,additionalHeaders]])

Creates an authentication header for the AWS Signature v4 specification.
This method can be utilized when programming directly with the HTTPS object.

NameTypeM/ODescriptionNote
hoststringmandatoryHTTP host
pathstringmandatoryHTTP path
methodstringmandatoryHTTP method
bodyToHashstringoptionalHTTP body
Specify when applying the Signed payload option. If not specified (default), the Unsigned payload option will be applied.
additionalHeadersobjectoptionalAdditional x-amz-* headers
x-amz-* headers can be additionally specified.
returnobject-Authorization Header
{ Authorization: <auth>, x-amz-content-sha256: <contenthash>, x-amz-date: <timestamp>}

.put(path,userHeaders,getBody,callback[,sockTo])

Sends data to the S3 bucket with a PUT request.

The host will be ${conig.bucket}.s3.amazonaws.com.
The authentication header is generated in this method and the Unsigned payload option is applied.

NameTypeM/ODescriptionNote
pathstringmandatorySpecify the path to the target resource.
userHeadersobjectmandatorySpecify HTTP request headers (HTTP/1.1 and x-amz-* headers).
"Content-Length" must be included.
getBodyfunctionmandatoryExecute callback processing at the timing when this method will accept the data (body) to be sent.
Returns data in string or ArrayBuffer chunks of 4KB or less until there is no more data, and finally returns null.
callback(err, resp)functionmandatoryExecute callback processing when this method is completed.
Notify the processing result using the argument of the callback function.
err: {HttpReqError}, null
resp: {HttpResponse}, null
If an error occurs in the HTTP request, err is set; if an HTTP response can be received, resp is set.
sockTonumberoptionalSpecify the HTTP session timeout value [ms].
This parameter is the sockTo setting value of the https.request() method. For details, refer to the HTTPS object specification.
v2.1.0+
returnundefined-

.get(path,callback[,isBin[,sockTo]])

Gets data from the S3 bucket with a GET request.

The host will be ${conig.bucket}.s3.amazonaws.com.
The authentication header is generated in this method and the Unsigned payload option is applied.

NameTypeM/ODescriptionNote
pathstringmandatorySpecify the path to the target resource.
callback(err, resp)functionmandatoryExecute callback processing when an HTTP response event occurs.
err: {HttpReqError}, null
resp: {HttpResponse}, null
If an error occurs in the HTTP request, err is set and the process ends. If an HTTP response could be received, resp is set. HTTP response data is split and notified in multiple callbacks. The end of processing can be determined by the HTTP response notification completion flag.
isBinbooleanoptionalSpecify the type of HTTP response data (resp).
true: ArrayBuffer
false: string
The default value is false.
v2.1.0+
sockTonumberoptionalSpecify the HTTP session timeout value [ms].
This parameter is the sockTo setting value of the https.request() method. For details, refer to the HTTPS object specification.
v2.1.0+
returnundefined-

.abortRequest()

Aborts the currently ongoing HTTP request.

NameTypeM/ODescriptionNote
returnundefined-

{HttpReqError}

NameTypeDescriptionNote
.errCodenumberThe error code of the HTTPS request
For details, refer to the error code table of the HTTPS object.

{HttpResponse}

NameTypeDescriptionNote
.statusCodenumberThe status code of the HTTP response
.statusMessagestringThe status message of the HTTP response
.bodystring, nullHTTP response data (Response-Body)
It may be null (no attached data) depending on the HTTP response content and the timing of HTTP reception.
.endFlagbooleanHTTP response notification completion flag
In the case of the .put() method, this flag will always be true as it is a batch notification.
In the case of the .get() method, the HTTP response data is split and notified in multiple callbacks. Continue retrieving response data until this flag becomes true.
true: Notification completed (End of processing)
false: Not completed. Wait for next callback notification.
v2.1.0+



Usage Examples

The following common code is used in all sample code:

Make sure that the root CA certificate is appropriate for the S3 endpoint in advance.
For information on how to obtain a CA certificate, please refer to here.

log.setLevel(0,2); //-1:NONE 0:ERROR 1:WARNING 2:DEBUG 3:TRACE, 0:DISABLE 1:LOG 2:CONSOLE 3:BOTH
log.printLevel(2); //0:DISABLE 1:LOG 2:CONSOLE 3:BOTH

var rootCa = '-----BEGIN CERTIFICATE-----\n...<CA>...\n-----END CERTIFICATE-----';

//TODO: Configuration
var s3 = new AWS_S3({
    region: <value>,
    accessKeyId: <value>,
    secretKey: <value>,
    bucket: <value>,
    ca: rootCa
});
if('errors' in s3) {
    //TODO: Handle errors
    throw new Error("Invalid configuration");
}

Sample 1

Send data to an S3 bucket.

var path = "/path/to/sample.txt";
var body = "sample text to send to S3";
var headers = s3.createXAmzHeaders({
    "ContentLength": body.length.toString()
});

var busy;
var getBody = function() {
    var temp = body;
    body = null;
    return temp;
};
var callback = function(err, resp) {
    if(err) {
        print("Error!", err.errCode);
    } else {
        print("Response:", resp.body);
        print("Status:", resp.statusCode, resp.statusMessage);
    }
    busy = false;
};

busy = true;
s3.put(path, headers, getBody, callback);
while(busy);
print("Done");

Sample 2

Add custom tags and ACL parameters and send data to an S3 bucket.

var path = "/path/to/sample.txt";
var body = "sample text to send to S3";
var headers = s3.createXAmzHeaders({
    "Tagging": "example=tag", //Requires the s3:PutObjectTagging permission
    "ACL": "bucket-owner-full-control", //Requires the s3:PutObjectAcl permission
    "ContentLength": body.length.toString()
});

var busy;
var getBody = function() {
    var temp = body;
    body = null;
    return temp;
};
var callback = function(err, resp) {
    if(err) {
        print("Error!", err.errCode);
    } else {
        print("Response:", resp.body);
        print("Status:", resp.statusCode, resp.statusMessage);
    }
    busy = false;
};

busy = true;
s3.put(path, headers, getBody, callback);
while(busy);
print("Done");

Sample 3

Send data in chunks to an S3 bucket.

var path = "/path/to/sample.txt";
var body = "";
while(body.length < 1024*2) body += "0123456789ABCDEF"; //sample text
var headers = s3.createXAmzHeaders({
    "ContentLength": body.length.toString()
});

var busy;
var chunkSize = 1024; //4KB or less
var index = 0;
var getBody = function() {
    var chunk = body.substring(index, index + chunkSize);
    if(chunk) {
        index = index + chunkSize;
        return chunk;
    }
    return null;
};
var callback = function(err, resp) {
    if(err) {
        print("Error!", err.errCode);
    } else {
        print("Response:", resp.body);
        print("Status:", resp.statusCode, resp.statusMessage);
    }
    busy = false;
};

busy = true;
s3.put(path, headers, getBody, callback);
while(busy);
print("Done");

Sample 4

Retrieve data from an S3 bucket.

var path = "/path/to/sample.txt";

var busy;
var callback = function(err, resp) {
    if(err) {
        print("Error!", err.errCode);
        busy = false;
    } else {
        print("Response:", resp.body);
        if(resp.endFlag) {
            print("Status:", resp.statusCode, resp.statusMessage);
            busy = false;
        }
    }
};

busy = true;
s3.get(path, callback);
while(busy);
print("Done");


The company names and product names mentioned above are registered trademarks or trademarks of their respective companies.

Updated: 2024-03-26
← RTC Alarm Synchronized SchedulerAWS IoT Core v2 →
  • Abstracts
    • {AWS_S3} Instance
  • Details
    • new AWS_S3([config])
    • .createXAmzHeaders(params)
    • .createHttpHeader(host,path,method[,bodyToHash[,additionalHeaders]])
    • .put(path,userHeaders,getBody,callback[,sockTo])
    • .get(path,callback[,isBin[,sockTo]])
    • .abortRequest()
    • {HttpReqError}
    • {HttpResponse}
  • Usage Examples
    • Sample 1
    • Sample 2
    • Sample 3
    • Sample 4
AboutNewsProductsFAQPrivacy PolicyVulnerability Disclosure Policy
NEQTO Console
IntroductionFundamentalsAdministrative ActionsDevice Management NEQTO Apps
NEQTO Bridge
NEQTO Bridge ModuleNEQTO Bridge Wi-Fi ModuleNEQTO Bridge LTE-1 ModuleError Logging Event Messages
API Documentation
API UsageGlobal APIRegional APIAPI Terms of Service
Jigsaw, Inc.
© 2025 JIG-SAW INC.