Skip to content

Commit e12aebf

Browse files
committed
use gzip for upload
1 parent ddfb5f0 commit e12aebf

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"lodash": "^4.17.21",
3434
"luxon": "^3.5.0",
3535
"mqtt": "^4.3.8",
36+
"pako": "^2.1.0",
3637
"popper.js": "^1.16.1",
3738
"stream-browserify": "^3.0.0",
3839
"url": "^0.11.4",

src/components/debug_config/LogCard.vue

+9-13
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import {
9393
} from "@fortawesome/free-solid-svg-icons";
9494
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
9595
import axios from "axios";
96+
import pako from "pako";
9697
9798
library.add(fasFileDownload, fasSpinner, fasClipboard, fasShareNodes);
9899
@@ -259,26 +260,21 @@ export default {
259260
},
260261
async postToPastebin() {
261262
try {
262-
const response = await fetch("https://bytebin.openwb.de/post", {
263-
method: "POST",
263+
// Compress the log data using gzip
264+
const compressedData = pako.gzip(this.logData);
265+
266+
const response = await axios.post("https://bytebin.openwb.de/post", compressedData, {
264267
headers: {
265-
"Content-Type": "text/log",
268+
"Content-Type": "application/octet-stream",
269+
"Content-Encoding": "gzip",
266270
},
267-
body: this.logData,
268271
});
269272
270-
if (!response.ok) {
271-
throw new Error("Network response was not ok");
272-
}
273-
274-
const responseData = await response.json();
275-
const pastebinKey = responseData.key;
276-
if (!pastebinKey) {
277-
console.log(responseData);
273+
if (!response.data.key) {
278274
throw new Error("Key is missing in the response");
279275
}
280-
console.log(responseData);
281276
277+
const pastebinKey = response.data.key;
282278
this.pastebinLink = `https://paste.openwb.de/${pastebinKey}`;
283279
console.log("Pastebin link:", this.pastebinLink);
284280
this.copyToClipboard(this.pastebinLink, false);

0 commit comments

Comments
 (0)