public void FolderPutCreateFolderTest()
        {
            var path = Path.Combine(TempFolderPath, "TestFolder0");

            //PutCreate folder
            var request = new PutCreateFolderRequest();

            request.Path        = path;
            request.Storage     = StorageName;
            request.DestStorage = StorageName;
            CreateFolderResponse response = null;

            try
            {
                response = StorageApi.PutCreateFolder(request);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("not supported"), ex.Message);
                return;
            }

            Assert.AreEqual(200, response.Code);

            //The folder should exists on path
            var fileExist = FileExist(StorageName, path);

            Assert.IsTrue((bool)fileExist.IsExist);
            Assert.IsTrue((bool)fileExist.IsFolder);
        }
Exemplo n.º 2
0
        public void FolderPutCreateFolderTest()
        {
            PutCreateFolderRequest request = new PutCreateFolderRequest();

            request.path        = Path.Combine(dataFolder, "folder1");
            request.storage     = storageName;
            request.destStorage = destStorageName;
            var response = FolderApi.PutCreateFolder(request);

            Assert.AreEqual(200, response.Code);
        }
        public void SetUp()
        {
            #region Add folders

            try
            {
                for (var i = 1; i <= 2; i++)
                {
                    var request = new PutCreateFolderRequest();
                    request.Path        = string.Format("{0}/TestFolder{1}", TempFolderPath, i);
                    request.Storage     = StorageName;
                    request.DestStorage = DestStorageName;

                    var response = StorageApi.PutCreateFolder(request);
                    Assert.AreEqual(200, response.Code);
                }
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("not supported"), ex.Message);
            }

            #endregion

            #region Add files
            {
                var request = new PutCreateRequest()
                {
                    Storage = StorageName, VersionId = null
                };

                for (var i = 1; i <= 2; i++)
                {
                    //Add TestFile.data
                    request.File = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6 });
                    request.Path = string.Format("{0}/TestFolder{1}/TestFile{1}.data", TempFolderPath, i);
                    var response = StorageApi.PutCreate(request);
                    Assert.AreEqual(200, response.Code);
                }

                //Add FileVersion.data - first version
                request.Path = string.Format("{0}/FileVersion.data", TempFolderPath);
                request.File = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6 });
                var responseVersion = StorageApi.PutCreate(request);
                Assert.AreEqual(200, responseVersion.Code);

                //Add FileVersion.data - second version
                request.File    = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6, 7 });
                responseVersion = StorageApi.PutCreate(request);
                Assert.AreEqual(200, responseVersion.Code);
            }
            #endregion
        }
        /// <summary>
        /// Create the folder
        /// </summary>
        /// <param name="request">Request. <see cref="PutCreateFolderRequest" /></param>
        /// <returns><see cref="CreateFolderResponse"/></returns>
        public CreateFolderResponse PutCreateFolder(PutCreateFolderRequest request)
        {
            // verify the required parameter 'path' is set
            if (request.path == null)
            {
                throw new ApiException(400, "Missing required parameter 'path' when calling PutCreateFolder");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/storage/folder";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "path", request.path);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.storage);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destStorage", request.destStorage);

            try
            {
                var response = this.apiInvoker.InvokeApi(
                    resourcePath,
                    "PUT",
                    null,
                    null,
                    null);
                if (response != null)
                {
                    return((CreateFolderResponse)SerializationHelper.Deserialize(response, typeof(CreateFolderResponse)));
                }

                return(null);
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }

                throw;
            }
        }