add https checking

This commit is contained in:
fyears 2024-03-25 00:43:13 +08:00
parent e228250613
commit e2e8265d43
2 changed files with 15 additions and 1 deletions

View File

@ -22,7 +22,7 @@ import { buildQueryString } from "@smithy/querystring-builder";
import { HeaderBag, HttpHandlerOptions, Provider } from "@aws-sdk/types"; import { HeaderBag, HttpHandlerOptions, Provider } from "@aws-sdk/types";
import { Buffer } from "buffer"; import { Buffer } from "buffer";
import * as mime from "mime-types"; import * as mime from "mime-types";
import { Vault, requestUrl, RequestUrlParam } from "obsidian"; import { Vault, requestUrl, RequestUrlParam, Platform } from "obsidian";
import { Readable } from "stream"; import { Readable } from "stream";
import * as path from "path"; import * as path from "path";
import AggregateError from "aggregate-error"; import AggregateError from "aggregate-error";
@ -770,6 +770,13 @@ export const checkConnectivity = async (
callbackFunc?: any callbackFunc?: any
) => { ) => {
try { try {
// TODO: no universal way now, just check this in connectivity
if (Platform.isIosApp && !s3Config.s3Endpoint.startsWith("https")) {
throw Error(
`Your s3 endpoint could only be https, not http, because of the iOS restriction.`
);
}
// const results = await s3Client.send( // const results = await s3Client.send(
// new HeadBucketCommand({ Bucket: s3Config.s3BucketName }) // new HeadBucketCommand({ Bucket: s3Config.s3BucketName })
// ); // );

View File

@ -228,6 +228,13 @@ export class WrappedWebdavClient {
if (this.client !== undefined) { if (this.client !== undefined) {
return; return;
} }
if (Platform.isIosApp && !this.webdavConfig.address.startsWith("https")) {
throw Error(
`Your webdav address could only be https, not http, because of the iOS restriction.`
);
}
const headers = { const headers = {
"Cache-Control": "no-cache", "Cache-Control": "no-cache",
}; };