Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from NfoAlex/FixFileAttatchment
Browse files Browse the repository at this point in the history
Fix file attatchment
  • Loading branch information
NfoAlex authored Jun 2, 2023
2 parents ce9d5b1 + adcf0e5 commit 9f938b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const e = require("express");

const port = process.env.PORT || 33333;

const SERVER_VERSION = "alpha_20230530";
const SERVER_VERSION = "alpha_20230602";

const app = express();
const server = http.createServer(app);
Expand Down Expand Up @@ -91,16 +91,21 @@ app.get('/file/:channelid/:fileid', (req, res) => {
let fileid = req.params.fileid; //ファイルIDを取得
let channelid = req.params.channelid; //チャンネルIDを取得

let fileidPathName = ""; //JSONファイル名
let fileidIndex = {}; //JSONファイルから取り出したJSONそのもの

//JSONファイルの取り出し準備
try {
//ファイルIDからJSON名を取得(日付部分)
let fileidPathName = fileid.slice(0,4) + "_" + fileid.slice(4,6) + "_" + fileid.slice(6,8);
fileidPathName = fileid.slice(0,4) + "_" + fileid.slice(4,6) + "_" + fileid.slice(6,8);
//ファイルIDインデックスを取得
let fileidIndex = JSON.parse(fs.readFileSync('./fileidIndex/' + channelid + '/' + fileidPathName + '.json', 'utf-8')); //ユーザーデータのJSON読み込み
fileidIndex = JSON.parse(fs.readFileSync('./fileidIndex/' + channelid + '/' + fileidPathName + '.json', 'utf-8')); //ユーザーデータのJSON読み込み
} catch(e) {
console.log("index :: app.get('/file/') : ファイル送信失敗", e);
console.log("index :: app.get('/file/') : ファイル送信失敗", fileid, e);
res.send("内部エラー");
}

//JSONから添付ファイルを探して返す
try {
//ファイルを返す
console.log("返すファイルデータ :: ", fileidIndex[fileid]);
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9f938b3

Please sign in to comment.