-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imprv: Upload handler use apiv3 post #8279
Conversation
router.post('/add', uploads.single('file'), accessTokenParser, loginRequired, apiV3FormValidator, addActivity, async(req, res) => { | ||
const pageId = req.body.page_id || null; | ||
const pagePath = req.body.path || null; | ||
|
||
// check params | ||
if (req.file == null) { | ||
return res.apiv3Err('File error.'); | ||
} | ||
if (pageId == null && pagePath == null) { | ||
return res.apiv3Err('Either page_id or path is required.'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同じくバリデーションを作ってください。そうすればこのあたりの処理もいらなくなる?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req
直下のバリデーションが無理そうだったので req.file
は残しました。
また、pagePath
はあったとしても使わず、pageId == null, pagePath == なにか
という状況ではファイルのアップロードができないことからそもそも pagePath
を入れるのをやめました。
*/ | ||
router.get('/limit', accessTokenParser, loginRequiredStrictly, validator.retrieveFileLimit, apiV3FormValidator, async(req, res) => { | ||
const { fileUploadService } = crowi; | ||
const fileSize = Number(req.query.fileSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number() で囲っているけれど、validator.isNumeric() で検証しているので不要だと思う。
/attachment/limit
を使っている個所は一か所しかなく number 型が入ってくる
accessToken を使ったときに対応しているのか?
ただ、その場合でも isNumeric() により検証できるようになるはず。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
クエリパラメータはテキストで渡るので number 型へのキャストが必要
if (pageId == null) { | ||
formData.append('page_body', codeMirrorEditor?.getDoc() ?? ''); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接 PR に関係ないですが、この処理は必要でしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
page_body を使用しなかったので、消しました。
*/ | ||
router.get('/limit', accessTokenParser, loginRequiredStrictly, validator.retrieveFileLimit, apiV3FormValidator, async(req, res) => { | ||
const { fileUploadService } = crowi; | ||
const fileSize = Number(req.query.fileSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
クエリパラメータはテキストで渡るので number 型へのキャストが必要
* @apiParam {String} path | ||
* @apiParam {File} file | ||
*/ | ||
router.post('/add', uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly, excludeReadOnlyUser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
router.post('/',
でいいと思います
reg-suit detected visual differences. Check this report, and review them. 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵 What do the circles mean?The number of circles represent the number of changed images.🔴 : Changed items, ⚪ : New items, ⚫ : Deleted items, and 🔵 Passed items How can I change the check status?If reviewers approve this PR, the reg context status will be green automatically. |
概要
PageEditor.tsx
の uploadHandler 内で添付ファイルの作成に apiv3 を使用するように変更Task
コメントの削除について
editorRef.current.insertText(insertText);
codeMirrorEditor?.insertText(insertText);
に変更したため削除editorRef.current.terminateUploadingState();