public void Validate(IUploadParameters parameters)
        {
            _uploadClientRequiredParametersValidator.Validate(parameters);

            if (parameters.MediaCategory == MediaCategory.Gif || parameters.MediaCategory == MediaCategory.Image ||
                parameters.MediaCategory == MediaCategory.DmGif || parameters.MediaCategory == MediaCategory.DmImage)
            {
                var maxUploadSize = Limits.UPLOAD_MAX_IMAGE_SIZE;
                if (parameters.Binary.Length > maxUploadSize)
                {
                    throw new TwitterArgumentLimitException($"{nameof(parameters)}.{nameof(parameters.Binary)}", maxUploadSize, nameof(Limits.UPLOAD_MAX_IMAGE_SIZE), "binary size");
                }
            }

            if (parameters.MediaCategory == MediaCategory.Video || parameters.MediaCategory == MediaCategory.DmVideo)
            {
                var maxUploadSize = Limits.UPLOAD_MAX_VIDEO_SIZE;
                if (parameters.Binary.Length > maxUploadSize)
                {
                    throw new TwitterArgumentLimitException($"{nameof(parameters)}.{nameof(parameters.Binary)}", maxUploadSize, nameof(Limits.UPLOAD_MAX_VIDEO_SIZE), "binary size");
                }
            }
        }
Example #2
0
 public Task <IChunkUploadResult> UploadBinary(IUploadParameters parameters)
 {
     _uploadClientRequiredParametersValidator.Validate(parameters);
     return(ExecuteRequest(request => _uploadQueryExecutor.UploadBinary(parameters, request)));
 }