diff --git a/app/api/routes/progressive_storage.py b/app/api/routes/progressive_storage.py index 652aa32..72b239b 100644 --- a/app/api/routes/progressive_storage.py +++ b/app/api/routes/progressive_storage.py @@ -7,6 +7,7 @@ from mimetypes import guess_type import aiofiles from base58 import b58encode +from base64 import b64decode from sanic import response from app.core.logger import make_log @@ -34,6 +35,7 @@ async def s_api_v1_5_storage_post(request): return response.json({"error": "Invalid X-Content-SHA256 header format"}, status=400) provided_filename = request.headers.get("X-File-Name") + provided_filename = b64decode(provided_filename).decode("utf-8") # Check if the file already exists in the database db_session = request.ctx.db_session diff --git a/uploader_test.html b/uploader_test.html index b2ce0a9..b0ed2d1 100644 --- a/uploader_test.html +++ b/uploader_test.html @@ -107,16 +107,18 @@ const hashHex = await computeSHA256(file); appendLog(`Computed SHA-256 hash: ${hashHex}`); - // Prepare the POST request with file as body and header X-Content-SHA256 + // Prepare the POST request with file as body and additional header for filename + const encodedFileName = btoa(unescape(encodeURIComponent(file.name))); const response = await fetch(BASE_URL, { method: "POST", headers: { "X-Content-SHA256": hashHex, - "X-File-Name": file.name, // NEW: передаём имя файла + "X-File-Name": encodedFileName, // NEW: передаём имя файла в base64 "Content-Type": file.type || "application/octet-stream" }, body: file }); + if (!response.ok) { const errorData = await response.json();