Em đang làm 1 chức năng là upload avatar lên web bằng java nhưng không biết lưu như thế nào. Anh chị có thể chỉ cho em cách lưu được không ạ
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Em có thể nói cụ thể hơn là em đang dùng framework nào không em?
Em dùng java web glashfish jdk8 chỉ dùng servlet thuần thôi ạ. Kết nối với mysq ạ
Em có thể tham khảo code này nhé:
vâng ạ, e cảm ơn. A ơi có nên lưu base64 vào db không ạ
Không nên em ạ, bởi vì để biến byte array thành base64 và ngược lại sẽ bị chậm, thêm nữa nếu làm vậy dữ liệu sẽ phải lưu buffer trên mem rồi mới đọc ghi xuống db được, đối với những file lớn có thể tràn bộ nhớ. Việc đọc ghi DB cũng chậm do phải thông qua network, vậy tốt nhất là lưu ở máy cần download file, nếu là hệ thống lớn thì tổ chức thành cdn như amazone s3 em ạ.