Beispiel #1
0
        public ISendStreamRequest <FileItem> Upload(string name, string dir = null, string dir_id = null, DateTime modificationTime = default(DateTime), DateTime dirModificationTime = default(DateTime), UploadMode mode = UploadMode.CreateOnly)
        {
            var request = new SendStreamRequest <FileItem>(RequestUrl, Client);

            switch (mode)
            {
            case UploadMode.CreateOnly:
                request.Method = "POST";
                break;

            case UploadMode.CreateOrUpdate:
                request.Method = "PUT";
                break;

            default:
                throw new NotImplementedException();
            }

            request.QueryOptions.Add(new KeyValuePair <string, string>("name", Uri.EscapeDataString(name)));
            if (dir != null)
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("dir", Uri.EscapeDataString(dir)));
            }
            if (dir_id != null)
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("dir_id", dir_id));
            }
            if (modificationTime != default(DateTime))
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("mtime", new DateTimeOffset(modificationTime).ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture)));
            }
            if (dirModificationTime != default(DateTime))
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("parent_mtime", new DateTimeOffset(dirModificationTime).ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture)));
            }

            return(request);
        }
Beispiel #2
0
        public ISendStreamRequest Patch(string path = null, string pid = null, DateTime modificationTime = default(DateTime),
                                        long offset = 0)
        {
            var request = new SendStreamRequest(RequestUrl, Client)
            {
                Method = "PATCH"
            };

            if (path != null)
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("path", Uri.EscapeDataString(path)));
            }
            if (pid != null)
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("pid", pid));
            }
            if (modificationTime != default(DateTime))
            {
                request.QueryOptions.Add(new KeyValuePair <string, string>("mtime", new DateTimeOffset(modificationTime).ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture)));
            }
            request.QueryOptions.Add(new KeyValuePair <string, string>("offset", offset.ToString(CultureInfo.InvariantCulture)));
            return(request);
        }