MCPcopy
hub / github.com/codedogQBY/ReadAny / constructor

Method constructor

packages/core/src/sync/s3-backend.ts:163–199  ·  view source on GitHub ↗
(config: S3Config, secretAccessKey: string)

Source from the content-addressed store, hash-verified

161 private remoteRoot: string;
162
163 constructor(config: S3Config, secretAccessKey: string) {
164 this.remoteRoot =
165 sanitizeS3RemoteRoot(config.remoteRoot ?? DEFAULT_S3_REMOTE_ROOT) || DEFAULT_S3_REMOTE_ROOT;
166 this.config = {
167 ...config,
168 remoteRoot: this.remoteRoot,
169 };
170 let requestHandler: PlatformFetchHttpHandler | undefined;
171 try {
172 const platform = getPlatformService();
173 if (platform.isDesktop) {
174 requestHandler = new PlatformFetchHttpHandler();
175 }
176 } catch {
177 // Platform service may not be initialized in tests that never touch S3.
178 }
179
180 // Auto-detect path-style for non-AWS endpoints. Self-hosted S3-compatible
181 // servers (rclone serve s3, MinIO, IP/localhost endpoints) overwhelmingly
182 // require path-style addressing because their hostname can't carry the
183 // bucket as a subdomain. AWS S3 supports both styles, so leave that alone.
184 // Users can still override via the UI toggle.
185 const pathStyle = config.pathStyle ?? shouldDefaultToPathStyle(config.endpoint);
186
187 const clientConfig = {
188 endpoint: config.endpoint,
189 region: config.region,
190 credentials: {
191 accessKeyId: config.accessKeyId,
192 secretAccessKey,
193 },
194 forcePathStyle: pathStyle,
195 ...(requestHandler ? { requestHandler } : {}),
196 };
197
198 this.client = new S3Client(clientConfig);
199 }
200
201 async testConnection(): Promise<boolean> {
202 try {

Callers

nothing calls this directly

Calls 3

sanitizeS3RemoteRootFunction · 0.90
getPlatformServiceFunction · 0.90
shouldDefaultToPathStyleFunction · 0.85

Tested by

no test coverage detected