//private void Upgrade() //{ // //For v2.0 we need to manually add some pre-values to the Articulate Cropper, // // https://github.com/Shazwazza/Articulate/issues/80 // // https://github.com/Shazwazza/Articulate/issues/135 // // The normal upgrade process will upgrade all of the other things apart from the addition of the pre-values // //For v3.0 we need to manually add some pre-values to the Articulate Cropper, // // https://github.com/Shazwazza/Articulate/issues/202 // var cropperDt = _dataTypeService.GetDataType("Articulate Cropper"); // if (cropperDt != null) // { // if (cropperDt.EditorAlias.InvariantEquals("Umbraco.ImageCropper")) // { // var preVals = cropperDt.ConfigurationAs<ImageCropperConfiguration>(); // if (preVals != null) // { // var crops = new ImageCropperConfiguration.Crop[] // { // new ImageCropperConfiguration.Crop { Alias = "square", Width = 480, Height = 480 }, // new ImageCropperConfiguration.Crop { Alias = "thumbnail", Width = 50, Height = 50 }, // new ImageCropperConfiguration.Crop { Alias = "wide", Width = 1024, Height = 512 }, // new ImageCropperConfiguration.Crop { Alias = "blogPost", Width = 200, Height = 200 } // }; // if (preVals.Crops == null || preVals.Crops.Length == 0) // { // preVals.Crops = crops; // _dataTypeService.Save(cropperDt); // } // else // { // //we should merge them since the developer may have added their own // var currentCrops = preVals.Crops; // var required = crops.ToDictionary(crop => crop.Alias, crop => false); // foreach (var cropAlias in currentCrops.Select(x => x.Alias)) // { // if (required.ContainsKey(cropAlias)) // required[cropAlias] = true; // } // //fill in the missing // foreach (var req in required) // { // if (!req.Value) // preVals.Crops.Append(crops.First(x => x.Alias == req.Key)); // } // preVals.Crops = crops; // _dataTypeService.Save(cropperDt); // } // } // } // } //} /// <summary> /// Ensure the media is saved with the media file system /// </summary> /// <remarks> /// Copy from the 'original' location to the 'default' /// </remarks> private void InstallMedia() { _mediaFileSystem.AddFile("articulate/default/logo.png", IOHelper.MapPath("~/media/articulate/original/logo.png"), true, true); _mediaFileSystem.AddFile("articulate/default/author.jpg", IOHelper.MapPath("~/media/articulate/original/author.jpg"), true, true); _mediaFileSystem.AddFile("articulate/default/banner.jpg", IOHelper.MapPath("~/media/articulate/original/banner.jpg"), true, true); _mediaFileSystem.AddFile("articulate/default/post1.jpg", IOHelper.MapPath("~/media/articulate/original/post1.jpg"), true, true); _mediaFileSystem.AddFile("articulate/default/post2.jpg", IOHelper.MapPath("~/media/articulate/original/post2.jpg"), true, true); }
object IMetaWeblog.NewMediaObject(string blogid, string username, string password, MetaWeblogMediaObject media) { ValidateUser(username, password); // Save File using (var ms = new MemoryStream(media.Bits)) { var fileUrl = "articulate/" + media.Name.ToSafeFileName(); _mediaFileSystem.AddFile(fileUrl, ms); return(new { url = fileUrl }); } }
private ParseImageResponse ParseImages(string body, MultipartFileStreamProvider multiPartRequest, bool extractFirstImageAsProperty) { var firstImage = string.Empty; var bodyText = Regex.Replace(body, @"\[i:(\d+)\:(.*?)]", m => { var index = m.Groups[1].Value.TryConvertTo <int>(); if (index) { //get the file at this index var file = multiPartRequest.FileData[index.Result]; var rndId = Guid.NewGuid().ToString("N"); using (var stream = File.OpenRead(file.LocalFileName)) { var fileUrl = "articulate/" + rndId + "/" + file.Headers.ContentDisposition.FileName.TrimStart("\"").TrimEnd("\""); _mediaFileSystem.AddFile(fileUrl, stream); var result = string.Format("![{0}]({1})", fileUrl, fileUrl ); if (extractFirstImageAsProperty && string.IsNullOrEmpty(firstImage)) { firstImage = fileUrl; //in this case, we've extracted the image, we don't want it to be displayed // in the content too so don't return it. return(string.Empty); } return(result); } } return(m.Value); }); return(new ParseImageResponse { BodyText = bodyText, FirstImage = firstImage }); }
private string ProcessFile(ContentPropertyData editorValue, ContentPropertyFile file, string currentPath, Guid cuid, Guid puid) { // process the file // no file, invalid file, reject change if (UploadFileTypeValidator.ValidateFileExtension(file.FileName) == false) { return(null); } // get the filepath // in case we are using the old path scheme, try to re-use numbers (bah...) var filepath = _mediaFileSystem.GetMediaPath(file.FileName, currentPath, cuid, puid); // fs-relative path using (var filestream = File.OpenRead(file.TempFilePath)) { // TODO: Here it would make sense to do the auto-fill properties stuff but the API doesn't allow us to do that right // since we'd need to be able to return values for other properties from these methods _mediaFileSystem.AddFile(filepath, filestream, true); // must overwrite! } return(filepath); }