mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Use direct url for png, jpeg, bmp
This commit is contained in:
parent
037906833b
commit
8783779d2f
1 changed files with 18 additions and 5 deletions
|
@ -84,7 +84,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
case "done":
|
case "done":
|
||||||
case "ready":
|
case "ready":
|
||||||
MediaCrushBlob blob = jsonResponse[hash].ToObject<MediaCrushBlob>();
|
MediaCrushBlob blob = jsonResponse[hash].ToObject<MediaCrushBlob>();
|
||||||
result.URL = blob.URL;
|
result.URL = blob.DirectURL;
|
||||||
result.DeletionURL = blob.DeletionURL;
|
result.DeletionURL = blob.DeletionURL;
|
||||||
return result;
|
return result;
|
||||||
case "unrecognized":
|
case "unrecognized":
|
||||||
|
@ -121,7 +121,7 @@ private UploadResult HandleDuplicate(HttpWebResponse httpResponse)
|
||||||
|
|
||||||
return new UploadResult
|
return new UploadResult
|
||||||
{
|
{
|
||||||
URL = blob.URL,
|
URL = blob.DirectURL,
|
||||||
DeletionURL = blob.DeletionURL
|
DeletionURL = blob.DeletionURL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ private UploadResult CheckExists(string hash)
|
||||||
|
|
||||||
return new UploadResult(response)
|
return new UploadResult(response)
|
||||||
{
|
{
|
||||||
URL = blob.URL,
|
URL = blob.DirectURL,
|
||||||
DeletionURL = blob.DeletionURL
|
DeletionURL = blob.DeletionURL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -190,12 +190,12 @@ public string DirectURL
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Files != null && Files.Length > 0)
|
if (Files != null && Files.Length > 0 && IsDirectURLPossible(Files[0]))
|
||||||
{
|
{
|
||||||
return "https://mediacru.sh" + Files[0].Path;
|
return "https://mediacru.sh" + Files[0].Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return URL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,5 +207,18 @@ public string DeletionURL
|
||||||
return "https://mediacru.sh/" + Hash + "/delete";
|
return "https://mediacru.sh/" + Hash + "/delete";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsDirectURLPossible(MediaCrushFile file)
|
||||||
|
{
|
||||||
|
switch (file.Mimetype)
|
||||||
|
{
|
||||||
|
case "image/png":
|
||||||
|
case "image/jpeg":
|
||||||
|
case "image/bmp":
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue