mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-30 20:20:34 +12:00
Use direct url for png, jpeg, bmp
This commit is contained in:
parent
037906833b
commit
8783779d2f
|
@ -84,7 +84,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
case "done":
|
||||
case "ready":
|
||||
MediaCrushBlob blob = jsonResponse[hash].ToObject<MediaCrushBlob>();
|
||||
result.URL = blob.URL;
|
||||
result.URL = blob.DirectURL;
|
||||
result.DeletionURL = blob.DeletionURL;
|
||||
return result;
|
||||
case "unrecognized":
|
||||
|
@ -121,7 +121,7 @@ private UploadResult HandleDuplicate(HttpWebResponse httpResponse)
|
|||
|
||||
return new UploadResult
|
||||
{
|
||||
URL = blob.URL,
|
||||
URL = blob.DirectURL,
|
||||
DeletionURL = blob.DeletionURL
|
||||
};
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ private UploadResult CheckExists(string hash)
|
|||
|
||||
return new UploadResult(response)
|
||||
{
|
||||
URL = blob.URL,
|
||||
URL = blob.DirectURL,
|
||||
DeletionURL = blob.DeletionURL
|
||||
};
|
||||
}
|
||||
|
@ -190,12 +190,12 @@ public string DirectURL
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Files != null && Files.Length > 0)
|
||||
if (Files != null && Files.Length > 0 && IsDirectURLPossible(Files[0]))
|
||||
{
|
||||
return "https://mediacru.sh" + Files[0].Path;
|
||||
}
|
||||
|
||||
return null;
|
||||
return URL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,5 +207,18 @@ public string DeletionURL
|
|||
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