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

Function upload

apps/web/services/discord/attachments.ts:50–83  ·  view source on GitHub ↗
({
  attach,
  accountId,
  channelId,
  name,
  ext,
}: {
  attach: DiscordAttachments;
  accountId: string | null;
  channelId: string;
  name: string;
  ext: string;
})

Source from the content-addressed store, hash-verified

48}
49
50async function upload({
51 attach,
52 accountId,
53 channelId,
54 name,
55 ext,
56}: {
57 attach: DiscordAttachments;
58 accountId: string | null;
59 channelId: string;
60 name: string;
61 ext: string;
62}) {
63 try {
64 const response = await axios.get(attach.url || attach.proxy_url, {
65 responseType: 'arraybuffer',
66 });
67 if (response.data) {
68 const s3Key = [
69 BUCKET_PREFIX_FOR_ATTACHMENTS,
70 accountId,
71 channelId,
72 random() + name + ext,
73 ]
74 .filter((e) => e)
75 .join('/');
76 await uploadFile({ Key: s3Key, Body: response.data });
77 return [LINEN_STATIC_CDN, s3Key].join('/');
78 }
79 } catch (error) {
80 console.error(error);
81 }
82 return null;
83}

Callers 2

handleAttachmentFunction · 0.85
uploadFilesFunction · 0.85

Calls 4

uploadFileFunction · 0.90
errorMethod · 0.65
randomFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected