Example #1
0
        public async Task <bool> SaveFilesAsync(ContentURI uri, XmlDocument doc,
                                                string fullURIPath, List <Stream> sourceStreams)
        {
            bool bHasCompleted = false;

            if (Path.IsPathRooted(fullURIPath))
            {
                //the xml does not need to be .xml (it could be .opf)
                XmlFileIO xmlIO = new XmlFileIO();
                bHasCompleted = await xmlIO.SaveFilesAsync(doc, fullURIPath,
                                                           sourceStreams);
            }
            else
            {
                PLATFORM_TYPES ePlatform = uri.URIDataManager.PlatformType;
                if (ePlatform == PLATFORM_TYPES.azure)
                {
                    AzureIOAsync azureIO = new AzureIOAsync(uri);
                    bHasCompleted = await azureIO.SaveBlobsAsync(doc, fullURIPath,
                                                                 sourceStreams);
                }
            }
            return(bHasCompleted);
        }
Example #2
0
        public static async Task <bool> CopyRelatedDataToPackageAsync(
            ContentURI uri, string currentFilePath,
            string packageName, string fileType, string newFilePath,
            bool needsAllRelatedData, IDictionary <string, string> zipArgs)
        {
            bool bHasCopied = false;

            FileStorageIO.PLATFORM_TYPES platform
                = uri.URIDataManager.PlatformType;
            if (platform == FileStorageIO.PLATFORM_TYPES.webserver)
            {
                bHasCopied = await CopyRelatedDataToWebServerPackageAsync(
                    uri, currentFilePath, packageName, fileType, newFilePath,
                    needsAllRelatedData, zipArgs);
            }
            else if (platform == FileStorageIO.PLATFORM_TYPES.azure)
            {
                AzureIOAsync azureIO = new AzureIOAsync(uri);
                bHasCopied = await azureIO.CopyRelatedDataToCloudServerPackageAsync(
                    uri, currentFilePath,
                    packageName, fileType, newFilePath, needsAllRelatedData, zipArgs);
            }
            return(bHasCopied);
        }
Example #3
0
        public static async Task <bool> CopyURIsAsync(ContentURI uri,
                                                      string fromURIPath, string toURIPath)
        {
            bool bHasCopied = false;

            //2.0.0 refactored from URIAbsoluteExists(fromURIPath) because azure uses localhost to debug
            if (await FileExistsAsync(uri, fromURIPath) == true &&
                fromURIPath.Equals(toURIPath) == false &&
                (!string.IsNullOrEmpty(toURIPath)))
            {
                PLATFORM_TYPES ePlatform = uri.URIDataManager.PlatformType;
                if (Path.IsPathRooted(fromURIPath))
                {
                    if (Path.IsPathRooted(toURIPath))
                    {
                        bHasCopied = await FileIO.CopyFilesAsync(
                            uri, fromURIPath, toURIPath);
                    }
                    else
                    {
                        if (ePlatform == PLATFORM_TYPES.azure)
                        {
                            //2.0.0 debugs azure blob storage using localhost
                            //note topath and frompath are reversed below
                            ePlatform = GetPlatformType(toURIPath);
                            if (ePlatform == PLATFORM_TYPES.azure)
                            {
                                AzureIOAsync azureIO = new AzureIOAsync(uri);
                                bHasCopied = await azureIO.SaveFileinCloudAsync(fromURIPath, toURIPath);
                            }
                            else
                            {
                                if (ePlatform == PLATFORM_TYPES.webserver)
                                {
                                    WebServerFileIO webIO = new WebServerFileIO();
                                    bHasCopied = await webIO.CopyWebFileToFileSystemAsync(toURIPath, fromURIPath);
                                }
                            }
                        }
                        else
                        {
                            //web server doesn't handle https and should use filesystem
                        }
                    }
                }
                else
                {
                    if (Path.IsPathRooted(toURIPath))
                    {
                        if (ePlatform == PLATFORM_TYPES.azure)
                        {
                            //2.0.0 debugs azure blob storage using localhost
                            ePlatform = GetPlatformType(fromURIPath);
                            if (ePlatform == PLATFORM_TYPES.azure)
                            {
                                AzureIOAsync azureIO = new AzureIOAsync(uri);
                                bHasCopied = await azureIO.SaveCloudFileAsync(fromURIPath, toURIPath);
                            }
                            else
                            {
                                if (ePlatform == PLATFORM_TYPES.webserver)
                                {
                                    WebServerFileIO webIO = new WebServerFileIO();
                                    bHasCopied = await webIO.CopyWebFileToFileSystemAsync(fromURIPath, toURIPath);
                                }
                            }
                        }
                        else
                        {
                            //210: to debug using localhost:5001
                            ePlatform = GetPlatformType(fromURIPath);
                            if (ePlatform == PLATFORM_TYPES.webserver)
                            {
                                WebServerFileIO webIO = new WebServerFileIO();
                                bHasCopied = await webIO.CopyWebFileToFileSystemAsync(fromURIPath, toURIPath);
                            }
                        }
                    }
                    else
                    {
                        if (ePlatform == PLATFORM_TYPES.azure)
                        {
                            AzureIOAsync azureIO = new AzureIOAsync(uri);
                            bHasCopied = await azureIO.CopyBlobAsync(
                                uri, fromURIPath, toURIPath);
                        }
                        else
                        {
                            //web server doesn't handle https and should use filesystem
                        }
                    }
                }
            }
            return(bHasCopied);
        }