#[SOLVED] Upload big file with SDK too many requests

8 messages · Page 1 of 1 (latest)

ember violet
#

Hi all,

for a few month I use in my nuxt application the appwrite sdk to upload videos to my bucket. It worked like a charm but now I get too many requests errors.
The only thing I changed is, I updated to Appwrite 1.5.3 I didn't test the video upload directly after I updated so it could be this change.
I updated also the SDK to latest version "appwrite": "^14.0.0" but still get this too many requests error.

Any Idea how I can debug this?

btw: Uploading in the Appwrite Backend works perfectly fine.

spark peak
#

Can you show your code?

ember violet
#

sure

  const uploadVideoFile = async (
    file: File,
    teamid: string | undefined,
    progress: (event: UploadProgress) => void,
  ) => {
    const { storage, ID } = useAppwrite();
    try {
      const permission = [];
      if (teamid) {
        permission.push(Permission.read(Role.team(teamid)));
        permission.push(Permission.write(Role.team(teamid, "owner")));
      }

      const res = await storage.createFile(
        VIDEO_BUCKET,
        ID.unique(),
        file,
        permission,
        progress,
      );
      return {
        success: true,
        data: res,
        error: null,
      };
    } catch (err) {
      if (err instanceof AppwriteException) {
        return {
          success: false,
          data: null,
          error: err.message,
        };
      } else {
        return {
          success: false,
          data: null,
          error: "Unkown Error",
        };
      }
    }
  };

my upload utils function. Component in the second post

#
interface VideoFile {
  name: string;
  src: string; // Object URL for preview
  type: string; // MIME type of the video
  file: File; // The actual File object for upload
  size: number;
  duration: number | null;
  status: string;
}
const videos = ref<VideoFile[]>([]);

const onProgressFactory = (video: VideoFile) => {
  return (event: UploadProgress) => {
    video.status = `Uploading: ${Math.round(event.progress)}%`;
  };
};

const uploadAllFiles = async () => {
  for (const video of videos.value) {
    video.status = "Starting upload...";

    try {
      const fileUpload = await uploadVideoFile(
        video.file,
        editStore.teamID,
        onProgressFactory(video),
      );

      if (!fileUpload.success && fileUpload.error) {
        new Error(fileUpload.error);
      }
// creating a document in the db with the upload infos if success.
ember violet
#

ok If I look at the network tab in Chrome DevTools th parts are really small. 327 B The total File Size is 1.8 GB
Here is the Payload:

$createdAt:"2024-03-25T17:41:30.979+00:00"
$id:"6601b74aebc55e5ac4d5"
$permissions:["read("team:65fd90808a4607e5755e")", "update("team:65fd90808a4607e5755e/owner")",]
$updatedAt:"2024-03-25T17:43:19.128+00:00"
bucketId:"651155e99b8b3b3523d4"
chunksTotal:372
chunksUploaded:62
mimeType:""
name:"Test-2024_03_21.mp4"
signature:""
sizeOriginal:1948037178

Is maybe the calculation for the chunks wrong?

spark peak
#

Can you show exactly what are the errors in the browser console? maybe the network tab will help to debug as well

ember violet
#

Ok error is gone. I didn't change anything so, I will have a look at this and change this to solved. @spark peak thanks for think along.

#

[solved] Upload big file with SDK too many requests