Skip to content

Commit

Permalink
fix phone camera (Imgur)
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jul 12, 2023
1 parent a3f4ee9 commit 546f855
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src_cef/package.json
Expand Up @@ -35,7 +35,7 @@
"@fortawesome/fontawesome-free": "^5.15.4",
"@jaames/iro": "^5.5.2",
"autoprefixer": "^9.8.8",
"axios": "^0.21.4",
"axios": "^1.4.0",
"babel-loader": "^8.2.5",
"cache-loader": "^4.1.0",
"canvas-scratch-card": "^1.0.4",
Expand All @@ -60,7 +60,6 @@
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.34",
"progressbar.js": "^1.1.0",
"qs": "^6.10.3",
"rage-rpc": "^0.4.0",
"request": "^2.88.2",
"sass-loader": "^13.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src_cef/src/App.svelte
@@ -1,7 +1,7 @@
<script>
let isMultiplayer = window.mp && window.mp.events;
document.api = "https://api.redage.net/";
document.imgurClientId = "ec243f05d2bc44b";
import 'lang/index'
//import '@/advertisement';
Expand Down
55 changes: 36 additions & 19 deletions src_cef/src/api/imgSave.js
Expand Up @@ -64,24 +64,41 @@ window.screenshot_getbase64 = async (url) => {
}

const getUrl = (dataURL) => {
axios.post(document.api + 'save', qs.stringify({
base64image: dataURL
}), config)
.then(function (response) {
if (response && response.data) {
response = response.data;

if (response.link) {
window.listernEvent ('cameraLink', response.link);
} else if (response.error) {
window.notificationAdd(4, 9, response.error, 3000);
}
}
uploadToImgur(dataURL)
.then(() => {
console.log("Image uploaded to Imgur successfully");
})
axios.post(document.api + 'test')
.then(function (response) {
if (response && response.data) {
response = response.data;
.catch((error) => {
console.error("Failed to upload image to Imgur:", error);
window.notificationAdd(4, 9, error.message, 3000);
});
};

const uploadToImgur = async (base64Image) => {
try
{
const response = await axios.post(
"https://api.imgur.com/3/image",
{
image: base64Image,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Client-ID ${document.imgurClientId}`,
},
}
);

if (response.status === 200)
{
const link = response.data.data.link;
window.listernEvent("cameraLink", link);
}
})
}

}
catch (error)
{
console.error("Failed to upload image to Imgur:", error);
}
};
2 changes: 1 addition & 1 deletion src_client/phone/camera/index.js
Expand Up @@ -93,7 +93,7 @@ const onScreen = async () => {
nameImg = Date.now() + ".jpg";
mp.gui.takeScreenshot(nameImg, 0, 100, 0);

screenshotsBrowser = mp.browsers.new(`screenshots://${nameImg}`);
screenshotsBrowser = mp.browsers.new(`http://screenshots/${nameImg}`);

onDestroy (true);

Expand Down

0 comments on commit 546f855

Please sign in to comment.