# Transfer Service 1.0 Implementation The Transfer service provides a unified interface for file exchange between remote locations and the local device. It serves multiple purposes: - Downloading application updates - Exchanging monitoring and administrative data - Uploading device information and logs - Managing content distribution for modules - Standardizing HTTP communication (POST, GET, etc.) for other services ## Store Concept The service uses a flexible "store" abstraction to manage different storage locations. This design allows: - Configuration-based location management - Multiple storage backends - Context-specific storage (logs, updates, monitoring) - Easy switching between storage implementations ### Store Configuration Stores are configured using JSON serialized configuration. Example from a production setup: ```json { "store_name": "config", "bucket_name": "etabelone-dev-etabelonedevbootstrape71b79bd-kfzemjujlgbe", "region": "eu-west-1", "prefix": "" } ``` ## Service Configuration The service can be configured through environment variables and service properties: ### Environment Variables | Environment Variable | Description | Example | |---------------------|-------------|---------| | AWS_ACCESS_KEY_ID | AWS Access key for authentication | AKIATCKAQOQG77TZDSOH | | AWS_SECRET_ACCESS_KEY | AWS Secret key for authentication | teEFXxZFWy10AzvQGSLTwGzqPq67hnY3rYk3MHzvV | | S3_STORE_CUSTOM_HOSTANDPORT_ENDPOINT | if aws is not used, this define the host and port to call | | S3_STORE_CUSTOM_HTTP_SCHEME | if S3_CUSTOM STORE is used, this define the protocol (can be either http or https) | | STORE_CONFIGURATION | JSON serialized store configuration | See store configuration example above | ### Service Properties The service can be configured as part of the application definition: ```json { "application_id": "aws_factory_transfert-1.0", "service_name": "transfer", "service_port": 8015, "application_description": "transfer files to aws, with default aws device enrollment access", "additional_properties": { "AWS_ACCESS_KEY_ID": "AKIATCKAQOQG77TZDSOH", "AWS_SECRET_ACCESS_KEY": "teEFXxZFWy10AzvQGSLTwGzqPq67hnY3rYk3MHzvV", "AWS_STORE_CONFIGURATION": "[{\"store_name\":\"config\",\"bucket_name\":\"etabelone-dev-etabelonedevbootstrape71b79bd-kfzemjujlgbe\",\"region\":\"eu-west-1\",\"prefix\":\"\"}]" } } ``` ## Store Implementations The service currently supports two storage backends: 1. **Filesystem Store** - Local file/folder storage - Used for testing and validation - Simple configuration with local paths 2. **AWS S3 Store** - Cloud storage implementation - Production-ready configuration - Supports multiple buckets and regions - Requires AWS credentials and bucket configuration ## Methods ### HTTP Request Method The service provides a standardized way to make HTTP requests to external servers: ```python call_service('transfer', 'http_request', 'https://www.google.fr', 'GET', {}, "") ``` Response format: ```json { "headers": [...], "httpcode": 200, "response_body": "..." } ``` ## Usage Examples ### AWS S3 Store Configuration For AWS S3 storage, configure the store with: - Store name (e.g., "config") - Bucket name (e.g., "etabelone-dev-...") - AWS region (e.g., "eu-west-1") - Optional prefix for object organization ### HTTP Communication The service standardizes HTTP communication for other modules: - GET requests for data retrieval - POST requests for data submission - Support for custom headers and body content - Response handling with status codes and headers ### Example of http_request calling from an other service/module sending and http GET request to an external webserver, example : ``` call_service('transfer','http_request','https://www.google.fr','GET',{},"") ``` this returns : ``` { "headers": [ "date: Sun, 23 Feb 2025 15:57:58 GMT", "expires: -1", "cache-control: private, max-age=0", "content-type: text/html; charset=ISO-8859-1", "content-security-policy-report-only: object-src 'none';base-uri 'self';script-src 'nonce-7vwSUhE3dcP7hy_mah_bDg' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp", "accept-ch: Sec-CH-Prefers-Color-Scheme", "p3p: CP=\"This is not a P3P policy! See g.co/p3phelp for more info.\"", "server: gws", "x-xss-protection: 0", "x-frame-options: SAMEORIGIN", "set-cookie: AEC=AVcja2ek4TuDGhyVR32F4wio5orc3vTLcsRvNye-GRM3i_8YyeP2EIvNr8Q; expires=Fri, 22-Aug-2025 15:57:58 GMT; path=/; domain=.google.fr; Secure; HttpOnly; SameSite=lax", "set-cookie: __Secure-ENID=25.SE=iwktx4Am0W8OAF3ucW4LzTDvBpXYMPXa162ZlQP1HBDPG6RhYMGfLv7ERi04bHspPt6qG-Q8Y6fTHQMIt83iDi2_9Z3jlNDxCi1MSap9HlaxCTKX7JERTO81u8xr1F_JRyZyoYzOu5RSSYyPlgJJHQ_jj_-qxXWklb3ndC8Iwc9PYrG-loTm6NrXZSMA0e6DP4N3oRBzY4VfjSJbRS3YNzwfZL2IZigHVx53aIldSCX1QUsmi1P0; expires=Thu, 26-Mar-2026 08:16:16 GMT; path=/; domain=.google.fr; Secure; HttpOnly; SameSite=lax", "alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000", "accept-ranges: none", "vary: Accept-Encoding", "transfer-encoding: chunked" ], "httpcode": 200, "response_body": "