MCPcopy Create free account
hub / github.com/VadimNotJustDev/SignalClone / sendImage

Function sendImage

components/MessageInput/MessageInput.tsx:185–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

183 };
184
185 const sendImage = async () => {
186 if (!image) {
187 return;
188 }
189 const blob = await getBlob(image);
190 const { key } = await Storage.put(`${uuidv4()}.png`, blob, {
191 progressCallback,
192 });
193
194 // send message
195 const user = await Auth.currentAuthenticatedUser();
196 const newMessage = await DataStore.save(
197 new Message({
198 content: message,
199 image: key,
200 userID: user.attributes.sub,
201 chatroomID: chatRoom.id,
202 replyToMessageID: messageReplyTo?.id,
203 })
204 );
205
206 updateLastMessage(newMessage);
207
208 resetFields();
209 };
210
211 const getBlob = async (uri: string) => {
212 const respone = await fetch(uri);

Callers 1

onPressFunction · 0.85

Calls 3

getBlobFunction · 0.85
updateLastMessageFunction · 0.85
resetFieldsFunction · 0.85

Tested by

no test coverage detected