-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdropboxDemo.ur
56 lines (47 loc) · 1.94 KB
/
dropboxDemo.ur
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(* For this demo, it's necessary to create dropboxSecrets.ur,
* defining [api_key] and [api_secret]. *)
structure D = Dropbox.Make(Dropbox.TwoLegged(DropboxSecrets))
fun create r =
m <- D.FileRequests.create ({Title = r.Title,
Destination = r.Destination}
++ Api.optionals {});
return <xml><body>ID: {[m.Id]}</body></xml>
fun download path =
u <- D.Sharing.createSharedLinkWithSettings {Path = path,
Settings = Api.optionals {RequestedVisibility = Dropbox.VisPublic,
Access = Dropbox.Viewer}};
redirect (bless u)
fun req id =
r <- D.FileRequests.get id;
fs <- (case r.Destination of
None => return []
| Some d => D.Files.listFolder ({Path = d} ++ Api.optionals {}));
return <xml><body>
Title: {[r.Title]}<br/>
URL: {[r.Url]}<br/>
Created: {[r.Created]}<br/>
Open: {[r.IsOpen]}<br/>
FileCount: {[r.FileCount]}<br/>
Destination: {[r.Destination]}<br/>
Description: {[r.Description]}
<h4>Files</h4>
<ul>
{List.mapX (fn f => <xml><li>{case f.PathDisplay of
None => <xml>{[f.Nam]}</xml>
| Some p => <xml><a link={download p}>{[f.Nam]}</a></xml>} ({[f.PathDisplay]})</li></xml>) fs}
</ul>
</body></xml>
val main =
rs <- D.FileRequests.list;
return <xml><body>
<h3>Requests</h3>
<ul>
{List.mapX (fn r => <xml><li><a link={req r.Id}>{[r.Title]}</a> <i>({[r.Created]}, {[r.FileCount]})</i> <a href={bless r.Url}>[Upload]</a></li></xml>) rs}
</ul>
<h3>Create Request</h3>
<form>
Title: <textbox{#Title}/><br/>
Destination: <textbox{#Destination}/><br/>
<submit action={create}/>
</form>
</body></xml>