31 lines
845 B
JavaScript
31 lines
845 B
JavaScript
const Minio = require('minio');
|
|
|
|
const BUCKET_NAME = 'sample-data';
|
|
|
|
const minioClient = new Minio.Client({
|
|
endPoint: 'localhost',
|
|
port: 9000,
|
|
useSSL: false,
|
|
accessKey: 'appuser',
|
|
secretKey: 'password123'
|
|
});
|
|
|
|
// ファイルアップロード(src/data/sample1.csv)
|
|
minioClient.presignedPutObject(BUCKET_NAME, 'sample2.csv',60 * 60, function(err, presignedUrl) {
|
|
if (err){
|
|
return console.log("file upload error:", err);
|
|
}
|
|
console.log('File uploaded URL:',presignedUrl);
|
|
// ダウンロードしたURLにPUTリクエストを送信する
|
|
});
|
|
|
|
// curl -X PUT -T .\src\data\sample2.csv "presignedUrl"
|
|
// const fileData = await fs.readFile(filePath);
|
|
// const res = await fetch(uploadUrl, {
|
|
// method: 'PUT',
|
|
// body: fileData,
|
|
// headers: {
|
|
// 'Content-Type': 'text/csv'
|
|
// }
|
|
// });
|