Add UploadFile() API.

This commit is contained in:
Yang Luo
2021-08-08 21:58:29 +08:00
parent 40fbca7db4
commit 5c2f96bda0
4 changed files with 33 additions and 23 deletions

View File

@ -18,6 +18,7 @@ import "cropperjs/dist/cropper.css";
import * as Setting from "./Setting";
import {Button, Row, Col, Modal} from 'antd';
import i18next from "i18next";
import * as UserBackend from "./backend/UserBackend";
export const CropperDiv = (props) => {
const [image, setImage] = useState("");
@ -25,7 +26,7 @@ export const CropperDiv = (props) => {
const [visible, setVisible] = React.useState(false);
const [confirmLoading, setConfirmLoading] = React.useState(false);
const {title} = props;
const {targetFunction} = props;
const {user} = props;
const {buttonText} = props;
let uploadButton;
@ -54,7 +55,8 @@ export const CropperDiv = (props) => {
return false;
}
// Setting.showMessage("success", "uploading...");
targetFunction(canvas.toDataURL());
const userId = `${user.owner}/${user.name}`;
UserBackend.uploadFile("avatar", userId, canvas.toDataURL());
return true;
}