Skip to content

Commit

Permalink
Add new languages for MediaInfo; Fixed upload of big files to Dropbox
Browse files Browse the repository at this point in the history
Set CURLOPT_POSTFIELDSIZE_LARGE option in the doUpload method of NetworkClient
Remove usage of CURLOPT_POSTFIELDSIZE_LARGE in the scripts
  • Loading branch information
zenden2k committed May 11, 2024
1 parent 146aab0 commit c31c64c
Show file tree
Hide file tree
Showing 16 changed files with 13,377 additions and 6,866 deletions.
4 changes: 0 additions & 4 deletions Data/Scripts/cloud.mail.ru.nut
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const CURLOPT_POSTFIELDSIZE = 60;

if(ServerParams.getParam("folder") == "") {
ServerParams.setParam("folder", "Screenshots") ;
}
Expand Down Expand Up @@ -183,7 +181,6 @@ function _SendMetaRequest(nc, url, remoteFileName, hashUpper, size, create) {
vec += _HexToBytes(hashUpper);
vec += create? "\x1": "\x0";
nm.setMethod("POST");
nm.setCurlOptionInt(CURLOPT_POSTFIELDSIZE, vec.len());
return nc.doUpload("", vec);
}

Expand All @@ -194,7 +191,6 @@ function _CreateFolder(nc, url, folderName) {
vec += folderName;
vec += "\x0\x0";
nm.setMethod("POST");
nm.setCurlOptionInt(CURLOPT_POSTFIELDSIZE, vec.len());
return nc.doUpload("", vec);
}

Expand Down
21 changes: 10 additions & 11 deletions Data/Scripts/dropbox.nut
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function UploadFile(FileName, options) {
if ( userPath!="" && userPath[userPath.len()-1] != "/") {
userPath+= "/";
}
local chunkSize = (50*1024*1024).tofloat();
const CHUNK_SIZE = 52428800;
local fileSize = 0;
try {
fileSize=GetFileSize(FileName);
Expand All @@ -180,8 +180,9 @@ function UploadFile(FileName, options) {
local path = "/"+ userPath;
local remotePath =path+ExtractFileName(FileName);
local fileId="";

if ( fileSize > 150000000 ) {
local chunkCount = ceil(fileSize / chunkSize);
local chunkCount = ceil(fileSize.tofloat() / CHUNK_SIZE);
local session = null;
local offset = 0;

Expand Down Expand Up @@ -215,26 +216,24 @@ function UploadFile(FileName, options) {
local json = _RegReplace(ToJSON(arg),"\n","");
nm.addQueryHeader("Dropbox-API-Arg", json);
}
local chunkSize = min(chunkSize,fileSize.tofloat()-offset).tointeger();
nm.setChunkSize(chunkSize);
local currentChunkSize = min(CHUNK_SIZE, fileSize - offset).tointeger();
nm.setChunkSize(currentChunkSize);
nm.addQueryHeader("Content-Type", "application/octet-stream");
nm.setUrl(url);
nm.doUpload(FileName,"");
if ( nm.responseCode() != 200 ) {
WriteLog("warning", "[dropbox.nut] Chunk upload failed, offset="+offset+", size="+chunkSize+(j< 1? "Trying again..." : ""));

if (nm.responseCode() != 200) {
WriteLog("warning", "[dropbox.nut] Chunk upload failed, offset="+offset+", size="+currentChunkSize+(j< 1? "Trying again..." : ""));
if ( nm.responseCode() == 403 ) {
WriteLog("error", "[dropbox.nut] Upload failed. Access denied");
return 0;
}
} else {
local t = ParseJSON(nm.responseBody());
if(session==""){
if (session==""){
session = t.session_id;
}else{

}
offset += chunkSize;
offset += currentChunkSize;

break;
}
Expand Down
4 changes: 0 additions & 4 deletions Data/Scripts/mediafire.nut
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const CURLOPT_POSTFIELDSIZE = 60;

function min(a,b) {
return a < b ? a : b;
}
Expand Down Expand Up @@ -183,7 +181,6 @@ function _ChunkedUpload(sessionToken, folderId, FileName, fileNameBase, fileSize
nm.setChunkOffset(offset);
nm.setChunkSize(currentChunk);
nm.setMethod("POST");
nm.setCurlOptionInt(CURLOPT_POSTFIELDSIZE, currentChunk);
nm.doUpload(FileName, "");

if (nm.responseCode() == 200) {
Expand Down Expand Up @@ -254,7 +251,6 @@ function UploadFile(FileName, options) {
nm.addQueryHeader("Content-Type", "application/octet-stream");
nm.setReferer("https://app.mediafire.com/");
nm.setMethod("POST");
nm.setCurlOptionInt(CURLOPT_POSTFIELDSIZE, fileSize);
nm.doUpload(FileName, "");

if (nm.responseCode() == 200) {
Expand Down
5 changes: 2 additions & 3 deletions Data/Scripts/onedrive.nut
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ function ModifyFolder(folder) {
}

function UploadFile(FileName, options) {
local fileSizeStr = GetFileSizeDouble(FileName).tostring();
local mimeType = GetFileMimeType(FileName);

local postData = {
Expand Down Expand Up @@ -351,8 +350,8 @@ function UploadFile(FileName, options) {
} else {
local t = ParseJSON(nm.responseBody());
local uploadUrl = t.uploadUrl;
local fileSize = GetFileSize(FileName);
local chunkCount = ceil(GetFileSizeDouble(FileName).tofloat() / CHUNK_SIZE);
local fileSize = GetFileSize(FileName).tointeger();
local chunkCount = ceil(fileSize.tofloat() / CHUNK_SIZE);

for ( local i = 0; i < chunkCount; i++) {
local offset = i * CHUNK_SIZE;
Expand Down
1 change: 0 additions & 1 deletion Data/Scripts/yandexdisk.nut
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ function _CheckIfExists(filename){

if (nm.responseCode() == 401) {
throw _GetAuthentificationErrorString(nm.responseCode());
return 0;
}
return (nm.responseCode() >= 200 && nm.responseCode() < 300);
}
Expand Down
Loading

0 comments on commit c31c64c

Please sign in to comment.