feat: update upload form content
This commit is contained in:
parent
b68ec64dee
commit
1dfdc10c30
|
|
@ -52,6 +52,7 @@ import Image from "next/image";
|
||||||
import { error, loading } from "@/config/swal";
|
import { error, loading } from "@/config/swal";
|
||||||
import { Item } from "@radix-ui/react-dropdown-menu";
|
import { Item } from "@radix-ui/react-dropdown-menu";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
import { getCsrfToken } from "@/service/auth";
|
||||||
|
|
||||||
interface FileWithPreview extends File {
|
interface FileWithPreview extends File {
|
||||||
preview: string;
|
preview: string;
|
||||||
|
|
@ -528,8 +529,16 @@ export default function FormAudio() {
|
||||||
// const placements = getPlacement(file.placements);
|
// const placements = getPlacement(file.placements);
|
||||||
// console.log("Placementttt: : ", placements);
|
// console.log("Placementttt: : ", placements);
|
||||||
|
|
||||||
|
const resCsrf = await getCsrfToken();
|
||||||
|
const csrfToken = resCsrf?.data?.token;
|
||||||
|
console.log("CSRF TOKEN : ", csrfToken);
|
||||||
|
const headers = {
|
||||||
|
"X-XSRF-TOKEN": csrfToken
|
||||||
|
};
|
||||||
|
|
||||||
const upload = new Upload(file, {
|
const upload = new Upload(file, {
|
||||||
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
||||||
|
headers: headers,
|
||||||
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
||||||
chunkSize: 20_000,
|
chunkSize: 20_000,
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|
@ -539,6 +548,10 @@ export default function FormAudio() {
|
||||||
duration,
|
duration,
|
||||||
isWatermark: "false", // hardcode
|
isWatermark: "false", // hardcode
|
||||||
},
|
},
|
||||||
|
onBeforeRequest: function (req) {
|
||||||
|
var xhr = req.getUnderlyingObject()
|
||||||
|
xhr.withCredentials = true
|
||||||
|
},
|
||||||
onError: async (e: any) => {
|
onError: async (e: any) => {
|
||||||
console.log("Error upload :", e);
|
console.log("Error upload :", e);
|
||||||
error(e);
|
error(e);
|
||||||
|
|
|
||||||
|
|
@ -543,8 +543,7 @@ export default function FormImage() {
|
||||||
const csrfToken = resCsrf?.data?.token;
|
const csrfToken = resCsrf?.data?.token;
|
||||||
console.log("CSRF TOKEN : ", csrfToken);
|
console.log("CSRF TOKEN : ", csrfToken);
|
||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": "application/json",
|
"X-XSRF-TOKEN": csrfToken
|
||||||
"X-XSRF-TOKEN": csrfToken,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const upload = new Upload(file, {
|
const upload = new Upload(file, {
|
||||||
|
|
@ -559,6 +558,10 @@ export default function FormImage() {
|
||||||
duration,
|
duration,
|
||||||
isWatermark: "true", // hardcode
|
isWatermark: "true", // hardcode
|
||||||
},
|
},
|
||||||
|
onBeforeRequest: function (req) {
|
||||||
|
var xhr = req.getUnderlyingObject()
|
||||||
|
xhr.withCredentials = true
|
||||||
|
},
|
||||||
onError: async (e: any) => {
|
onError: async (e: any) => {
|
||||||
console.log("Error upload :", e);
|
console.log("Error upload :", e);
|
||||||
error(e);
|
error(e);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ import Image from "next/image";
|
||||||
import { error, loading } from "@/config/swal";
|
import { error, loading } from "@/config/swal";
|
||||||
import { Item } from "@radix-ui/react-dropdown-menu";
|
import { Item } from "@radix-ui/react-dropdown-menu";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
import { getCsrfToken } from "@/service/auth";
|
||||||
|
|
||||||
interface FileWithPreview extends File {
|
interface FileWithPreview extends File {
|
||||||
preview: string;
|
preview: string;
|
||||||
|
|
@ -527,8 +528,16 @@ export default function FormTeks() {
|
||||||
// const placements = getPlacement(file.placements);
|
// const placements = getPlacement(file.placements);
|
||||||
// console.log("Placementttt: : ", placements);
|
// console.log("Placementttt: : ", placements);
|
||||||
|
|
||||||
|
const resCsrf = await getCsrfToken();
|
||||||
|
const csrfToken = resCsrf?.data?.token;
|
||||||
|
console.log("CSRF TOKEN : ", csrfToken);
|
||||||
|
const headers = {
|
||||||
|
"X-XSRF-TOKEN": csrfToken
|
||||||
|
};
|
||||||
|
|
||||||
const upload = new Upload(file, {
|
const upload = new Upload(file, {
|
||||||
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
||||||
|
headers: headers,
|
||||||
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
||||||
chunkSize: 20_000,
|
chunkSize: 20_000,
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|
@ -538,6 +547,10 @@ export default function FormTeks() {
|
||||||
duration,
|
duration,
|
||||||
isWatermark: "false", // hardcode
|
isWatermark: "false", // hardcode
|
||||||
},
|
},
|
||||||
|
onBeforeRequest: function (req) {
|
||||||
|
var xhr = req.getUnderlyingObject()
|
||||||
|
xhr.withCredentials = true
|
||||||
|
},
|
||||||
onError: async (e: any) => {
|
onError: async (e: any) => {
|
||||||
console.log("Error upload :", e);
|
console.log("Error upload :", e);
|
||||||
error(e);
|
error(e);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ import Image from "next/image";
|
||||||
import { error, loading } from "@/config/swal";
|
import { error, loading } from "@/config/swal";
|
||||||
import { Item } from "@radix-ui/react-dropdown-menu";
|
import { Item } from "@radix-ui/react-dropdown-menu";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
import { getCsrfToken } from "@/service/auth";
|
||||||
|
|
||||||
const CustomEditor = dynamic(
|
const CustomEditor = dynamic(
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -526,9 +527,16 @@ export default function FormVideo() {
|
||||||
|
|
||||||
// const placements = getPlacement(file.placements);
|
// const placements = getPlacement(file.placements);
|
||||||
// console.log("Placementttt: : ", placements);
|
// console.log("Placementttt: : ", placements);
|
||||||
|
const resCsrf = await getCsrfToken();
|
||||||
|
const csrfToken = resCsrf?.data?.token;
|
||||||
|
console.log("CSRF TOKEN : ", csrfToken);
|
||||||
|
const headers = {
|
||||||
|
"X-XSRF-TOKEN": csrfToken
|
||||||
|
};
|
||||||
|
|
||||||
const upload = new Upload(file, {
|
const upload = new Upload(file, {
|
||||||
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
endpoint: `${process.env.NEXT_PUBLIC_API}/media/file/upload`,
|
||||||
|
headers: headers,
|
||||||
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
retryDelays: [0, 3000, 6000, 12_000, 24_000],
|
||||||
chunkSize: 20_000,
|
chunkSize: 20_000,
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|
@ -538,6 +546,10 @@ export default function FormVideo() {
|
||||||
duration,
|
duration,
|
||||||
isWatermark: "false", // hardcode
|
isWatermark: "false", // hardcode
|
||||||
},
|
},
|
||||||
|
onBeforeRequest: function (req) {
|
||||||
|
var xhr = req.getUnderlyingObject()
|
||||||
|
xhr.withCredentials = true
|
||||||
|
},
|
||||||
onError: async (e: any) => {
|
onError: async (e: any) => {
|
||||||
console.log("Error upload :", e);
|
console.log("Error upload :", e);
|
||||||
error(e);
|
error(e);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue