コード例 #1
0
        public IEnumerator CreateContent(string @namespace, string userId, string accessToken, string channelId, string name, string type, string subtype,
                                         string[] tags, byte[] preview, string fileExtension, ResultCallback <UGCResponse> callback, string contentType)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't create content! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't create content! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create content! AccessToken parameter is null!");
            Assert.IsNotNull(channelId, "Can't create content! channelId parameter is null!");
            Assert.IsNotNull(name, "Can't create content! name parameter is null!");
            Assert.IsNotNull(type, "Can't create content! type parameter is null!");
            Assert.IsNotNull(subtype, "Can't create content! subType parameter is null!");
            Assert.IsNotNull(tags, "Can't create content! tags parameter is null!");
            Assert.IsNotNull(preview, "Can't create content! preview parameter is null!");
            Assert.IsNotNull(fileExtension, "Can't create content! fileExtension parameter is null!");

            UGCRequest createRequest = new UGCRequest
            {
                name          = name,
                type          = type,
                subtype       = subtype,
                tags          = tags,
                preview       = System.Convert.ToBase64String(preview),
                fileExtension = fileExtension,
                contentType   = contentType
            };

            yield return(CreateContent(@namespace, userId, accessToken, channelId, createRequest, callback));
        }
コード例 #2
0
        public IEnumerator CreateContent(string @namespace, string userId, string accessToken, string channelId, UGCRequest createRequest, ResultCallback <UGCResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't create content! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't create content! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create content! AccessToken parameter is null!");
            Assert.IsNotNull(channelId, "Can't create content! channelId parameter is null!");

            UGCRequest Req = createRequest;

            if (string.IsNullOrEmpty(Req.contentType))
            {
                Req.contentType = "application/octet-stream";
            }

            var request = HttpRequestBuilder
                          .CreatePost(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/channels/{channelId}/contents/s3")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("channelId", channelId)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(Req.ToUtf8Json())
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <UGCResponse>();

            callback.Try(result);
        }
コード例 #3
0
ファイル: UGC.cs プロジェクト: AccelByte/accelbyte-unity-sdk
        /// <summary>
        /// Modify existing content to update some information with string preview.
        /// </summary>
        /// <param name="channelId">The id of the content's channel.</param>
        /// <param name="contentId">The id of the content that will be modified.</param>
        /// <param name="ModifyRequest">Detail information for the content request that will be modified.</param>
        /// <param name="callback">This will be called when the operation succeeded. The result is UGCResponse Model.</param>
        public void ModifyContent(string channelId, string contentId, UGCRequest ModifyRequest, ResultCallback <UGCResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);

            if (!this.session.IsValid())
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);

                return;
            }

            this.coroutineRunner.Run(
                this.api.ModifyContent(this.@namespace, this.session.UserId, this.session.AuthorizationToken, channelId, contentId, ModifyRequest, callback));
        }