Looking for the old forum?

For topics posted before June 2015, please click here to visit the old support forum. Post your questions in this forum if you have any questions.

Support Forums
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12 Sep 2016 09:50 PM by  Pengtsen R
Support File providers
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages


New Member


Posts:18
New Member


--
07 Sep 2016 01:27 PM
    Module don't support folder providers for DotNetNuke and can't save file in other file servers (Windows Azure, Dropbox, Box (formerly Box.net), and FTP locations)
    For support providers only need to change in UploadHandler.ashx DoUpload
    this is code for support providers


    public static int DoUpload(PortalInfo objPortalInfo, AlbumInfo objAlbumInfo, Hashtable objSettings, UserInfo objUserInfo, HttpPostedFile uploadFile, ref string strMessage)
    {
    try
    {
    FileSystemController objFileSystemController = new FileSystemController(objPortalInfo, objAlbumInfo.ModuleId);
    if (objSettings[UPGSettingKey_String.WatermarkImage.ToString()]!=null)
    {
    string Left = objSettings[UPGSettingKey_String.WatermarkImage.ToString()].ToString();
    string str = objSettings[UPGSettingKey_String.ServerPath.ToString()].ToString();
    objFileSystemController.WaterMark = objPortalInfo.HomeDirectoryMapPath + str.Replace("/", "\\") + "\\" + Left;
    objFileSystemController.WMPosition = objSettings[UPGSettingKey_String.WatermarkPosition.ToString()].ToString();
    }
    if (uploadFile.ContentLength > 0)
    {
    DotNetNuke.Services.FileSystem.IFolderInfo folder = DotNetNuke.Services.FileSystem.FolderManager.Instance.GetFolder(objPortalInfo.PortalID, objAlbumInfo.ServerPath.Replace("\\", "/"));
    string fileName = objUserInfo.UserID.ToString() + "." + Utility.GetSafeFileName(Path.GetFileNameWithoutExtension(uploadFile.FileName)) + "." + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(uploadFile.FileName);
    DotNetNuke.Services.FileSystem.IFileInfo file = DotNetNuke.Services.FileSystem.FileManager.Instance.AddFile(folder, fileName, uploadFile.InputStream);

    int num = PhotoController.Add(objFileSystemController, objAlbumInfo, DotNetNuke.Services.FileSystem.FileManager.Instance.GetUrl(file), objUserInfo, false);
    if (num > 0)
    return num;
    strMessage = "The image is not uploaded";
    switch (num)
    {
    case -3:
    strMessage = "No more quota";
    break;
    case -2:
    strMessage = "Invalid format";
    break;
    case -1:
    strMessage = "UMG not activated.";
    break;
    default:
    strMessage = "Failed to save";
    break;
    }
    return -1;
    }
    else
    {
    strMessage = "No file uploaded";
    return -1;
    }
    }catch(Exception ex)
    {
    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
    strMessage = "No file uploaded";
    return -1;
    }
    }


    Basic Member


    Posts:189
    Basic Member


    --
    12 Sep 2016 09:50 PM
    This will be reviewed in future upgrades. Thanks for sharing this with us!
    You are not authorized to post a reply.


    Copyright © 2005-2013 BizModules Contact us