CloudUpload / content type w/azure storage

4 posts, 0 answers
  1. Travis
    Travis avatar
    1 posts
    Member since:
    Feb 2015

    Posted 19 Feb 2015 Link to this post

    Unless I'm trying things out incorrectly, it doesn't seem CloudUpload sets the content type upon successfully uploading a file to azure storage.

    I looked into the custom azure provider item, but doesn't seem to be an option to set content type.  

    Did I test this out wrong?  Is this a known bug?  Is there a workaround?
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 24 Feb 2015 Link to this post

    Hi Travis,

    At the moment CloudUpload set "application/octet-stream", which is a binary file. If you want to set different Content Type you will have to create Custom Azure Provider and override the default upload method:
            public virtual void UploadFileOnSigleRequest(string keyName, NameValueCollection metaData, Stream fileStream)
            {
    #if ASPNET35
                var blob = _container.GetBlobReference(keyName);
    #else
                var blob = _container.GetBlockBlobReference(keyName);
    #endif
                blob.Properties.ContentType = “application/x-shockwave-flash”;
      
                try
                {
                    blob.UploadFromStream(fileStream);
      
                    for (int i = 0; i < metaData.AllKeys.Length; i++)
                    {
                        var key = metaData.GetKey(i);
                        blob.Metadata.Add(key, metaData[key]);
                    }
                    blob.SetMetadata();
                }
                catch (Exception e)
                {
                    var message = string.Format("Exception thrown for upload operation for file with keyName: {0}", keyName);
                    throw new CloudUploadProviderException(message, e, keyName, BlobContainer);
                }
            }


    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phanindra
    Phanindra avatar
    1 posts
    Member since:
    Sep 2015

    Posted 20 Mar Link to this post

    HI Hristo Valyavicharski, 

    I followed your procedure, it is working as I expected, the problem is  According to the documentation setting UncommitedFilesExpirationPeriod affects "The time after the files are
    Deleted from the storage if they are not processed. I gave UncommitedFilesExpirationPeriod  as  2 hours, after 2 hours files were deleted in a container. How we make file is processed at  Custom Azure Provider.

     

    Thanks & Regards ,

    Phani B.

  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 23 Mar Link to this post

    Hi Phani,

    When you use a custom handler it just extends the existing, so the default functionality still should be working.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top