add alwaysUploadAsContent option

pull/63/head
shibao 2024-11-03 10:15:10 -05:00
parent c08e6473e9
commit f97e208550
3 changed files with 23 additions and 4 deletions

View File

@ -139,6 +139,17 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
</p>
</div>
<div class="col-12 md:col-6">
<label>
<input type="checkbox" v-model="cfg.alwaysUploadAsContent" />
Always upload as content
</label>
<p class="hint">
This will always upload the image content directly, instead of
as an URL
</p>
</div>
<span class="col-12 status-quiet">{{ versionInfo }}</span>
</div>
</TabPanel>

View File

@ -162,8 +162,12 @@ async function upload() {
try {
const post: ScrapedPostDetails = cloneDeep(pop.selectedPost)!;
// uploadMode "content" requires a content token to work. So ensure it is set.
if (post.uploadMode == "content") {
// uploadMode "content" requires a content token to work. So ensure it is
// set. Ignore fallback "Upload as URL" mode as well
if (
(cfg.value.alwaysUploadAsContent || post.uploadMode === "content")
&& post.name !== "[fallback] Upload as URL"
) {
await ensurePostHasContentToken(post);
}
@ -257,7 +261,10 @@ async function ensurePostHasContentToken(post: ScrapedPostDetails) {
}
try {
let tmpRes = await selectedInstance.uploadTempFile(post.contentUrl, post.uploadMode);
const uploadMode =
cfg.value.alwaysUploadAsContent && post.name !== "[fallback] Upload as URL" ?
'content' : post.uploadMode;
let tmpRes = await selectedInstance.uploadTempFile(post.contentUrl, uploadMode);
// Save contentToken in PostViewModel so that we can reuse it when creating/uploading the post.
instanceSpecificData.contentToken = tmpRes.token;
} catch (ex) {

View File

@ -14,6 +14,7 @@ export const cfg = useStorageLocal(
{
version: 0,
addPageUrlToSource: true,
alwaysUploadAsContent: false,
autoSearchSimilar: false,
loadTagCounts: true,
fetchPostInfo: true,