MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / uploadFiles

Function uploadFiles

apps/web/ui/ChannelView/ChatView/index.tsx:411–437  ·  view source on GitHub ↗
(files: File[])

Source from the content-addressed store, hash-verified

409 };
410
411 async function uploadFiles(files: File[]) {
412 setProgress(0);
413 setUploading(true);
414 setUploads([]);
415 const data = await getFormData(files);
416 return api
417 .upload(
418 { communityId: currentCommunity.id, data, type: 'attachments' },
419 {
420 onUploadProgress: (progressEvent: ProgressEvent) => {
421 const percentCompleted = Math.round(
422 (progressEvent.loaded * 100) / progressEvent.total
423 );
424 setProgress(percentCompleted);
425 },
426 }
427 )
428 .then(({ files }) => {
429 setUploading(false);
430 setUploads(files);
431 })
432 .catch((response) => {
433 setUploading(false);
434 setUploads([]);
435 return response;
436 });
437 }
438
439 function isPaginationView() {
440 return pathCursor && Number(pathCursor) > 0;

Callers 2

ChannelFunction · 0.70
ChatFunction · 0.50

Calls 2

getFormDataFunction · 0.90
uploadMethod · 0.65

Tested by

no test coverage detected