Beispiel #1
0
        public async Task Qiniu()
        {
            LCFile file = new LCFile("avatar", APKFilePath);
            await file.Save();

            TestContext.WriteLine(file.ObjectId);
            Assert.NotNull(file.ObjectId);
        }
Beispiel #2
0
        public async Task SaveFromPath()
        {
            avatar = new LCFile("avatar", AvatarFilePath);
            await avatar.Save((count, total) => {
                TestContext.WriteLine($"progress: {count}/{total}");
            });

            TestContext.WriteLine(avatar.ObjectId);
            Assert.NotNull(avatar.ObjectId);
        }
Beispiel #3
0
        public async Task AWS()
        {
            Logger.LogDelegate += Utils.Print;
            LeanCloud.Initialize("UlCpyvLm8aMzQsW6KnP6W3Wt-MdYXbMMI", "PyCTYoNoxCVoKKg394PBeS4r", "https://ulcpyvlm.api.lncldglobal.com");
            LCFile file = new LCFile("avatar", APKFilePath);
            await file.Save();

            TestContext.WriteLine(file.ObjectId);
            Assert.NotNull(file.ObjectId);
        }
Beispiel #4
0
        public async Task SaveFromMemory()
        {
            string text = "hello, world";

            byte[] data = Encoding.UTF8.GetBytes(text);
            LCFile file = new LCFile("text", data);
            await file.Save();

            TestContext.WriteLine(file.ObjectId);
            Assert.NotNull(file.ObjectId);
        }
Beispiel #5
0
        public async Task SaveFromUrl()
        {
            LCFile file = new LCFile("scene", new Uri("http://img95.699pic.com/photo/50015/9034.jpg_wh300.jpg"));

            file.AddMetaData("size", 1024);
            file.AddMetaData("width", 128);
            file.AddMetaData("height", 256);
            file.MimeType = "image/jpg";
            await file.Save();

            TestContext.WriteLine(file.ObjectId);
            Assert.NotNull(file.ObjectId);
        }
Beispiel #6
0
        public async Task FileACL()
        {
            LCUser user = await LCUser.LoginAnonymously();

            LCFile file = new LCFile("avatar", AvatarFilePath);
            LCACL  acl  = new LCACL();

            acl.SetUserReadAccess(user, true);
            file.ACL = acl;
            await file.Save();

            LCQuery <LCFile> query  = LCFile.GetQuery();
            LCFile           avatar = await query.Get(file.ObjectId);

            Assert.NotNull(avatar.ObjectId);

            await LCUser.LoginAnonymously();

            try {
                LCFile forbiddenAvatar = await query.Get(file.ObjectId);
            } catch (LCException e) {
                Assert.AreEqual(e.Code, 403);
            }
        }