Пример #1
0
        private async Task CopyFile(String json)
        {
            JObject   obj            = JObject.Parse(json);
            ImageFile downloadedFile = await DownloadFile(obj["imgId"].ToString());

            downloadedFile._id = obj["toUser"].ToString();
            ImageFileNoRev fileNoRev = new ImageFileNoRev(downloadedFile);
            var            response  = await CouchDBConnect.PostToDB(fileNoRev, "files");

            return;
        }
Пример #2
0
        public async Task <String> UploadFile([FromBody] ImageFile file)
        {
            if (VerifyTheToken(file._id))
            {
                ImageFileNoRev fileNoRev = new ImageFileNoRev(file);
                var            response  = await CouchDBConnect.PostToDB(fileNoRev, "files");

                Console.WriteLine(response);

                return("Upload Succeeded");
            }
            else
            {
                return("Please login first!");
            }
        }
Пример #3
0
        public async Task <string> ShareFile([FromBody] ShareFile sf)
        {
            if (VerifyTheToken(sf._id))
            {
                ShareFileNoRev shareNoRev = new ShareFileNoRev(sf);

                // check if toUser exist
                var response = await CouchDBConnect.PostToDB(shareNoRev, "shares");

                // create the same file with diffrenet id
                string json = JsonConvert.SerializeObject(shareNoRev);
                await client.PublishAsync(json);

                Console.WriteLine(response);
                return("Image shared to " + sf.toUser + " successfully");
            }
            else
            {
                return("Please login first!");
            }
        }