File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Example/DropboxClientExampleApp Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,17 @@ extension DropboxClient.Client: DependencyKey {
7171 return entry
7272 }
7373 return DeleteFile . Result ( metadata: entry)
74+ } ,
75+ uploadFile: . init { params in
76+ FileMetadata (
77+ id: " id:preview-uploaded " ,
78+ name: " Preview-uploaded.txt " ,
79+ pathDisplay: " /Preview-uploaded.txt " ,
80+ pathLower: " /preview-uploaded.txt " ,
81+ clientModified: Date ( ) ,
82+ serverModified: Date ( ) ,
83+ isDownloadable: true
84+ )
7485 }
7586 )
7687 } ( )
Original file line number Diff line number Diff line change @@ -93,6 +93,26 @@ struct ExampleView: View {
9393 } label: {
9494 Text ( " List Folder " )
9595 }
96+
97+ Button {
98+ Task < Void , Never > {
99+ do {
100+ _ = try await client. uploadFile (
101+ path: " /example-upload.txt " ,
102+ data: " swift-dropbox-client example uploaded file " . data ( using: . utf8) !,
103+ mode: . add,
104+ autorename: true
105+ )
106+ } catch {
107+ log. error ( " UploadFile failure " , metadata: [
108+ " error " : " \( error) " ,
109+ " localizedDescription " : " \( error. localizedDescription) "
110+ ] )
111+ }
112+ }
113+ } label: {
114+ Text ( " Upload file " )
115+ }
96116 }
97117
98118 if let list {
@@ -165,6 +185,27 @@ struct ExampleView: View {
165185 Text ( " Download File " )
166186 }
167187
188+ Button {
189+ Task < Void , Never > {
190+ do {
191+ _ = try await client. uploadFile (
192+ path: entry. pathDisplay,
193+ data: " Uploaded with overwrite at \( Date ( ) . formatted ( date: . complete, time: . complete) ) "
194+ . data ( using: . utf8) !,
195+ mode: . overwrite,
196+ autorename: false
197+ )
198+ } catch {
199+ log. error ( " UploadFile failure " , metadata: [
200+ " error " : " \( error) " ,
201+ " localizedDescription " : " \( error. localizedDescription) "
202+ ] )
203+ }
204+ }
205+ } label: {
206+ Text ( " Upload file (overwrite) " )
207+ }
208+
168209 Button ( role: . destructive) {
169210 Task < Void , Never > {
170211 do {
You can’t perform that action at this time.
0 commit comments