Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rick 92 posts 278 karma points
    Jul 22, 2015 @ 08:13
    Rick
    0

    Use Media Service to create media

    Hi,

    Does this also work with MediaService so that any media created in code is also pushed to Azure Blob Storage?

    (Umbraco 7.2.6)

    Thanks,

    Rick

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jul 22, 2015 @ 08:59
    Alex Skrypnyk
    0

    Hi Rick,

    It should work for Azure Blob Storage.

    Thanks

  • Rick 92 posts 278 karma points
    Jul 22, 2015 @ 09:23
    Rick
    0

    Hi Alex,

    Thanks very much for the quick response!

    Something like this is what I currently have:

    string originalPath = "uploadedImages\\test.png";
    
    IMediaService mediaService = ApplicationContext.Current.Services.MediaService;
    
    var newImage = mediaService.CreateMedia("myTestImage", -1, "Image");
    
    byte[] buffer = System.IO.File.ReadAllBytes(System.IO.Path.GetFullPath(HttpContext.Current.Server.MapPath(originalPath)));
    
    System.IO.MemoryStream strm = new MemoryStream(buffer);
    
    newImage.SetValue("umbracoFile", "myNewImage.png", strm);
    
    mediaService.Save(newImage);
    

    So are you saying that calling the mediaService.Save(newImage) method should automatically drop this into Blob Storage (assuming everything is set up correctly)?

    At the moment, it appears to be creating it in the default way (i.e. creating the media file in the media section of my file system).

    Many thanks,

    Rick

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jul 22, 2015 @ 10:06
    Alex Skrypnyk
    0

    Rick, did you make config changes for Azure Blob Storage ?

  • Rick 92 posts 278 karma points
    Jul 22, 2015 @ 10:10
    Rick
    0

    Hi Alex,

    Yes I have - according to the documentation on the package page.

    Thanks

    Rick

  • Dirk Seefeld 126 posts 665 karma points
    Jul 22, 2015 @ 10:48
    Dirk Seefeld
    0

    Hi Rick,

    try the regular media upload in Umbarco back office. When the uploaded files are in the cloud your configuration is fine.

    But if the MediaService does not store in the cloud it is an issue in the core and you should report this on:

    http://issues.umbraco.org/

    This package is just an implementation of IFileSystem and configured to be use for media items.

    Dirk

Please Sign in or register to post replies

Write your reply to:

Draft