ConcrntでRustFSを使おう!~MinIOからの移行~
この記事はAnthrotech Advent Calendar 2025の14日目の記事です!
昨日の記事は、 Lexerさんの 脳オルガノイド研究の今 でした。
おぉ・・・脳組織つかったコンピュータってあるんですね。初めて知った😮
簡単な記事の説明
ConcrntのストレージプロバイダにMinIOを使用していたのですが、メンテナンスモードに移行したみたいです。
READMEにもこのようなことが書かれているので、使うのはやめたほうが良さそう・・・
Critical security fixes may be evaluated on a case-by-case basis
[機械翻訳] 重大なセキュリティ修正は、ケースバイケースで評価される場合があります
ということで代替ソフトウェアとしてRustFSが良さそうだったので移行してみました。
インストール
環境に合わせてインストールしてください。
Windows版はComing Soonとなっていますが、GitHubのReleaseにあります。
ここからはWindows版を使用して説明していきます。
(多分ほかの環境でもさほど代わりはないと思う)
(Dockerは・・・ごめんわからん!)
起動
とりあえず起動してみます。
rustfs.exe --address :{APIサーバーのポート} --console-enable --console-address :{WebコンソールUIのポート} --access-key {アクセスキー} --secret-key {シークレットキー}
access-keyとsecret-keyはコンソールでログインするときにも使用するので簡単なものは避けましょう。
ブラウザからlocalhost:{WebコンソールUIのポート}にアクセスしてみてコンソールが表示できていれば起動完了。

設定
まずはバケットの設定から。
バケットを作成したあとに、SettingからAccess Policyを設定します。
内容はMinIOと同じものでOK。
自分が設定した内容
{
"ID": "",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": [
"*"
]
},
"Action": [
"s3:GetObject"
],
"NotAction": [],
"Resource": [
"arn:aws:s3:::concurrent/*"
],
"NotResource": [],
"Condition": {}
}
]
}
アクセスキーはAccess Keysから生成すればOK。
Concrntに設定する。
MinIOと同じ感じでOKなはず・・・!
MinIOからデータの移行
MinIOからデータを移行します。
一旦MinIOからダウンロードする。
全ファイルにチェックを入れてDownloadでできます。

RustFSにそのままアップロードすればOK・・・と行きたいところですが、Concrntからアップロードされたファイルには拡張子がついていません。
そのためそのままコンソールからアップロードするとContent-Typeが正しく設定されず、画像や動画がConcrntでうまく表示されないのでどうにかします。
NodeJSでフィアルの内容に合わせてContent-Typeを設定してアップロードするプログラムを作りました。(ほぼAI任せ)
MinIOからダウンロードしたファイルは、このプログラムを置いてあるディレクトリにminioというディレクトリを作成してその中に入れてください。
あとプログラム内のバケット名とかは変えてね。
NodeJSプログラム
{
"name": "rustfs-utils",
"version": "1.0.0",
"description": "Utility script to detect file types and upload to S3",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.500.0"
}
}
const fs = require('fs');
const path = require('path');
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
function getFilesRecursively(dir) {
let results = [];
const list = fs.readdirSync(dir, { withFileTypes: true });
for (const entry of list) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
results = results.concat(getFilesRecursively(fullPath));
} else if (entry.isFile()) {
results.push(fullPath);
}
}
return results;
}
/**
* Detect image type for a given file.
* - If the file has an extension, return it (without the dot, lowercased).
* - If no extension, read the first bytes and detect PNG or JPEG signatures.
* Returns: 'png' | 'jpeg' | other-extension | null (if unknown)
*/
async function detectImageType(filePath) {
const ext = path.extname(filePath).toLowerCase();
if (ext && ext.length > 0) {
return ext.startsWith('.') ? ext.slice(1) : ext;
}
// No extension: inspect file header
try {
const fd = await fs.promises.open(filePath, 'r');
// read a few more bytes to also detect MP4 (ftyp at offset 4)
const buffer = Buffer.alloc(12);
await fd.read(buffer, 0, 12, 0);
await fd.close();
// PNG signature: 89 50 4E 47 0D 0A 1A 0A
if (buffer[0] === 0x89 && buffer[1] === 0x50 && buffer[2] === 0x4E && buffer[3] === 0x47) {
return 'png';
}
// JPEG signature: FF D8 FF
if (buffer[0] === 0xFF && buffer[1] === 0xD8 && buffer[2] === 0xFF) {
return 'jpeg';
}
// MP4/QuickTime: 'ftyp' typically appears at offset 4
try {
const box = buffer.toString('ascii', 4, 8);
if (box === 'ftyp') return 'mp4';
} catch (e) {
// ignore and fallthrough
}
return null;
} catch (err) {
throw err;
}
}
function getContentTypeFromDetected(type) {
switch ((type || '').toLowerCase()) {
case 'jpeg':
case 'jpg':
return 'image/jpeg';
case 'png':
return 'image/png';
case 'mp4':
return 'video/mp4';
default:
return 'application/octet-stream';
}
}
async function uploadToS3(filePath, contentType) {
const region = "ap-northeast-1";
const bucket = {バケット名};
if (!bucket) throw new Error('S3 bucket not configured. Set S3_BUCKET env var.');
// Support S3-compatible endpoints (e.g., MinIO)
const endpoint = {Endpoint};
const accessKey = {Accesskey};
const secretKey = {SecretKey};
const clientConfig = {};
if (region) clientConfig.region = region;
if (endpoint) clientConfig.endpoint = endpoint;
// For S3-compatible servers you often need path-style addressing
clientConfig.forcePathStyle = true;
if (accessKey && secretKey) {
clientConfig.credentials = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
};
}
const client = new S3Client(clientConfig);
// Compute object key. By default strip a base directory (so local './minio' isn't
// included as a top-level folder in S3 keys). You can override the base to strip
// with `S3_STRIP_BASE` or `UPLOAD_BASE` env var. If strip base doesn't match,
// fall back to a relative path from cwd.
const stripBase = process.env.S3_STRIP_BASE || process.env.UPLOAD_BASE || './minio';
let key;
try {
const resolvedBase = path.resolve(stripBase);
const resolvedFile = path.resolve(filePath);
if (resolvedFile.startsWith(resolvedBase + path.sep) || resolvedFile === resolvedBase) {
key = path.relative(resolvedBase, resolvedFile);
} else {
key = path.relative(process.cwd(), resolvedFile);
}
} catch (e) {
key = path.relative(process.cwd(), filePath);
}
key = key.replace(/\\/g, '/');
const stream = fs.createReadStream(filePath);
const params = {
Bucket: bucket,
Key: key,
Body: stream,
ContentType: contentType,
};
await client.send(new PutObjectCommand(params));
return { bucket, key };
}
// Simple CLI: node index.js <file-or-directory-path>
if (require.main === module) {
(async () => {
// NOTE: Use internal variable instead of CLI argument as requested.
// Change this value to point at the target file or directory.
const INTERNAL_PATH = './minio';
const filePath = INTERNAL_PATH;
try {
const stat = await fs.promises.stat(filePath);
if (stat.isDirectory()) {
const files = getFilesRecursively(filePath);
for (const f of files) {
try {
const type = await detectImageType(f);
const contentType = getContentTypeFromDetected(type);
await uploadToS3(f, contentType);
console.log(`${f}: uploaded (${contentType})`);
} catch (e) {
console.error(`${f}: error (${e.message || e})`);
}
}
} else {
const type = await detectImageType(filePath);
const contentType = getContentTypeFromDetected(type);
try {
await uploadToS3(filePath, contentType);
console.log(`${filePath}: uploaded (${contentType})`);
} catch (e) {
console.error(`${filePath}: error (${e.message || e})`);
}
}
} catch (err) {
console.error('Error:', err.message || err);
process.exit(2);
}
})();
}
// This script is intended to be used as a CLI. module.exports removed per user preference.
あとがき
移行するのめんどくさいなぁと思っていたのですが、やってみたら思いの外簡単でした。
コンソールのUIもMinIOと近いので移行先としては良さそうです!
Discussion