Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 26, 2023
2 parents 0193c47 + 05384ca commit 490bc58
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 49 deletions.
4 changes: 2 additions & 2 deletions desk/desk.docket-0
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
info+'Start, host, and cultivate communities. Own your communications, organize your resources, and share documents. Groups is a decentralized platform that integrates with Talk, Notebook, and Gallery for a full, communal suite of tools.'
color+0xef.f0f4
image+'https://bootstrap.urbit.org/icon-groups.svg?v=1'
glob-http+['https://bootstrap.urbit.org/glob-0v1.kbjm8.h44sn.0rji5.upe8g.u5l9s.glob' 0v1.kbjm8.h44sn.0rji5.upe8g.u5l9s]
glob-http+['https://bootstrap.urbit.org/glob-0vpkb66.7906k.fhl40.sfbag.3h35r.glob' 0vpkb66.7906k.fhl40.sfbag.3h35r]
base+'groups'
version+[4 8 0]
version+[4 8 1]
website+'https://tlon.io'
license+'MIT'
==
4 changes: 2 additions & 2 deletions talk/desk.docket-0
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
info+'Send encrypted direct messages to one or many friends. Talk is a simple chat tool for catching up, getting work done, and everything in between.'
color+0x10.5ec7
image+'https://bootstrap.urbit.org/icon-talk.svg?v=1'
glob-http+['https://bootstrap.urbit.org/glob-0v3.5ef54.b2qo4.o8b4o.738uj.ok2k6.glob' 0v3.5ef54.b2qo4.o8b4o.738uj.ok2k6]
glob-http+['https://bootstrap.urbit.org/glob-0v7.lnq57.22fup.bdspn.9v0b5.gotem.glob' 0v7.lnq57.22fup.bdspn.9v0b5.gotem]
base+'talk'
version+[4 8 0]
version+[4 8 1]
website+'https://tlon.io'
license+'MIT'
==
2 changes: 1 addition & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title data-react-helmet="true">Loading...</title>
<meta name="theme-color" content="#ffffff" data-react-helmet="true" />
<link
Expand Down
115 changes: 71 additions & 44 deletions ui/src/state/storage/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,49 +127,73 @@ export const useFileStore = create<FileStore>((set, get) => ({
// respond with a redirect to a pre-signed url to the actual bucket. The
// token is in the url, not a header, so that it disappears after the
// redirect.
const requestOptions = {
method: 'PUT',
headers: {
'Content-Type': compressedFile.type,
},
body: compressedFile,
};
const { presignedUrl } = config;
const url = `${presignedUrl}/${key}`;
const token = await api.scry<string>({
app: 'genuine',
path: '/secret',
});
const urlWithToken = `${url}?token=${token}`;
fetch(urlWithToken, requestOptions)
.then(async (response) => {
if (response.status !== 200) {
const body = await response.text();
throw new Error(body || 'Incorrect response status');
}
// When the PUT succeeded, we fetch the actual URL of the file. We do
// this to avoid having to proxy every single GET request, and to
// avoid remembering which file corresponds to which bucket, when
// using multiple buckets internally.
const fileUrlResponse = await fetch(url);
const fileUrl = await fileUrlResponse.json();
updateStatus(uploader, key, 'success');
imageSize(fileUrl).then((s) =>
updateFile(uploader, key, {
size: s,
url: fileUrl,
})
);
})
.catch((error: any) => {
updateStatus(
uploader,
key,
'error',
`Tlon Hosting upload error: ${error.message}, contact support if it persists.`
);
console.log({ error });
});

try {
const requestOptions = {
method: 'PUT',
headers: {
'Content-Type': compressedFile.type,
},
body: compressedFile,
};
const { presignedUrl } = config;
const url = `${presignedUrl}/${key}`;
const token = await api
.scry<string>({
app: 'genuine',
path: '/secret',
})
.catch((e) => {
console.log('failed to get secret', { e });
return '';
});
const urlWithToken = `${url}?token=${token}`;
fetch(urlWithToken, requestOptions)
.then(async (response) => {
if (response.status !== 200) {
const body = await response.text().catch(() => {
console.log(
'Error parsing response body, body, response status not 200'
);
return '';
});
throw new Error(body || 'Incorrect response status');
}
// When the PUT succeeded, we fetch the actual URL of the file. We do
// this to avoid having to proxy every single GET request, and to
// avoid remembering which file corresponds to which bucket, when
// using multiple buckets internally.
const fileUrlResponse = await fetch(url);
const fileUrl = await fileUrlResponse.json().catch(() => {
console.log('Error parsing response body, fileUrlResponse');
return '';
});
updateStatus(uploader, key, 'success');
imageSize(fileUrl).then((s) =>
updateFile(uploader, key, {
size: s,
url: fileUrl,
})
);
})
.catch((error: any) => {
updateStatus(
uploader,
key,
'error',
`Tlon Hosting upload error: ${error.message}, contact support if it persists.`
);
console.log({ error });
});
} catch (error: any) {
updateStatus(
uploader,
key,
'error',
`Tlon Hosting upload error: ${error.message}, contact support if it persists.`
);
console.log({ error });
}
}

// Logic for uploading with S3.
Expand All @@ -183,7 +207,10 @@ export const useFileStore = create<FileStore>((set, get) => ({
ACL: 'public-read',
});

const url = await getSignedUrl(client, command);
const url = await getSignedUrl(client, command).catch((e) => {
console.log('failed to get signed url', { e });
return '';
});

client
.send(command)
Expand Down

0 comments on commit 490bc58

Please sign in to comment.