Correctly update preview url with object extension preferences

Rename variables for consistency
Early url returning for quicker pastes
This commit is contained in:
Matthew Burnett 2019-01-24 15:09:00 -05:00
parent ee4b7690b1
commit 21c5e764fc
4 changed files with 21 additions and 12 deletions

View file

@ -108,18 +108,13 @@ public override UploadResult Upload(Stream stream, string fileName)
string name = fileName;
if ((RemoveExtensionImage && Helpers.IsImageFile(fileName)) ||
(RemoveExtensionText && Helpers.IsTextFile(fileName)) ||
(RemoveExtensionVideo && Helpers.IsVideoFile(fileName)))
{
name = Path.GetFileNameWithoutExtension(fileName);
}
string uploadPath = GetUploadPath(name);
string uploadpath = GetUploadPath(name);
OnEarlyURLCopyRequested(GenerateURL(uploadPath));
GoogleCloudStorageMetadata metadata = new GoogleCloudStorageMetadata
{
name = uploadpath,
name = uploadPath,
acl = new GoogleCloudStorageAcl[]
{
new GoogleCloudStorageAcl
@ -137,13 +132,13 @@ public override UploadResult Upload(Stream stream, string fileName)
GoogleCloudStorageResponse upload = JsonConvert.DeserializeObject<GoogleCloudStorageResponse>(result.Response);
if (upload.name != uploadpath)
if (upload.name != uploadPath)
{
Errors.Add("Upload failed.");
return null;
}
result.URL = GenerateURL(uploadpath);
result.URL = GenerateURL(uploadPath);
return result;
}
@ -151,6 +146,14 @@ public override UploadResult Upload(Stream stream, string fileName)
private string GetUploadPath(string fileName)
{
string uploadPath = NameParser.Parse(NameParserType.FolderPath, Prefix.Trim('/'));
if ((RemoveExtensionImage && Helpers.IsImageFile(fileName)) ||
(RemoveExtensionText && Helpers.IsTextFile(fileName)) ||
(RemoveExtensionVideo && Helpers.IsVideoFile(fileName)))
{
fileName = Path.GetFileNameWithoutExtension(fileName);
}
return URLHelpers.CombineURL(uploadPath, fileName);
}

View file

@ -3137,16 +3137,19 @@ private void txtGoogleCloudStorageObjectPrefix_TextChanged(object sender, EventA
private void cbGoogleCloudStorageStripExtensionImage_CheckedChanged(object sender, EventArgs e)
{
Config.GoogleCloudStorageRemoveExtensionImage = cbGoogleCloudStorageStripExtensionImage.Checked;
UpdateGoogleCloudStorageStatus();
}
private void cbGoogleCloudStorageStripExtensionVideo_CheckedChanged(object sender, EventArgs e)
{
Config.GoogleCloudStorageRemoveExtensionVideo = cbGoogleCloudStorageStripExtensionVideo.Checked;
UpdateGoogleCloudStorageStatus();
}
private void cbGoogleCloudStorageStripExtensionText_CheckedChanged(object sender, EventArgs e)
{
Config.GoogleCloudStorageRemoveExtensionText = cbGoogleCloudStorageStripExtensionText.Checked;
UpdateGoogleCloudStorageStatus();
}
#endregion Google Cloud Storage

View file

@ -265,7 +265,10 @@ private void UpdateGoogleCloudStorageStatus()
{
Bucket = Config.GoogleCloudStorageBucket,
Domain = Config.GoogleCloudStorageDomain,
Prefix = Config.GoogleCloudStorageObjectPrefix
Prefix = Config.GoogleCloudStorageObjectPrefix,
RemoveExtensionImage = Config.GoogleCloudStorageRemoveExtensionImage,
RemoveExtensionText = Config.GoogleCloudStorageRemoveExtensionText,
RemoveExtensionVideo = Config.GoogleCloudStorageRemoveExtensionVideo
};
lblGoogleCloudStoragePathPreview.Text = gcs.GetPreviewURL();

View file

@ -455,7 +455,7 @@ public class TaskSettingsAdvanced
Editor("System.Windows.Forms.Design.StringCollectionEditor,System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
public List<string> ImageExtensions { get; set; }
[Category("Upload"), DefaultValue(false), Description("Copy URL before start upload. Only works for FTP, FTPS, SFTP and Dropbox public URLs.")]
[Category("Upload"), DefaultValue(false), Description("Copy URL before start upload. Only works for FTP, FTPS, SFTP, Dropbox, and Google Cloud Storage.")]
public bool EarlyCopyURL { get; set; }
[Category("Upload"), Description("Files with these file extensions will be uploaded using text uploader."),