You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MFilesAPI.Extensions/Files/Downloading/Readme.md
+90-65Lines changed: 90 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,71 +2,100 @@
2
2
3
3
## FileDownloadLocation
4
4
5
-
The `FileDownloadLocation.cs` class represents a physical folder on disk where temporary file downloads are stored. This class inherits from `IDisposable` and can automatically delete temporary files when the object is disposed:
5
+
The `FileDownloadLocation.cs` class represents a physical folder on disk where temporary files are stored. The system temporary folder path is automatically used if no specific folder location is provided.
6
+
7
+
This class implements the `IDisposable` interface and can automatically delete the content of the folder it represent when the object is disposed, if the value of the `CleanDirectoryOnDisposal` property is `true`.
8
+
9
+
Usage example, using the system default temporary folder path, and the assembly name as folder name:
// TODO: Perform operations on the downloaded file.
19
-
}
24
+
// TODO: Add, manipulate folders, files in that location,
25
+
// they will be automatically deleted when this object is disposed
26
+
// if CleanDirectoryOnDisposal is true,
27
+
// or deleted when downloadLocation.CleanTemporaryFiles() is called.
20
28
}
21
29
```
22
30
23
31
32
+
33
+
To use a specific location, simply use the constructor overload that takes a path, and a folder name:
34
+
35
+
```csharp
36
+
using (FileDownloadLocationdownloadLocation=newFileDownloadLocation(@"C:\temp", "myfolder"))
37
+
{
38
+
// The folder represented by this FileDownloadLocation instance is:
39
+
// C:\temp\myfolder
40
+
}
41
+
```
42
+
43
+
44
+
24
45
## TemporaryFileDownload
25
46
26
-
The `TemporaryFileDownload` class represents a download of a single file from the vault onto disk for temporary usage. Files can be downloaded with or without a `FileDownloadLocation` object, as appropriate:
47
+
The `TemporaryFileDownload` class represents a download of a single file from the vault onto disk for temporary usage.
48
+
49
+
This class implements the `IDisposable` interface and automatically deletes the temporary file it represents when the object is disposed.
50
+
51
+
It cannot be directly instantiated using the `new` keyword.
27
52
28
-
### Using the static method
53
+
Instances are either created using the `TemporaryFileDownload` class static method `Download`, or via the `DownloadFile` method of a `FileDownloadLocation` instance, or via extensions methods on `ObjectFile` instances.
54
+
55
+
### Using the `TemporaryFileDownload` static `Download` method
29
56
30
57
```csharp
31
58
// Download the file.
32
59
// It is assumed that objectFile and vault are already available/populated.
//BlockSize will be 8192 bytes instead of the default 4096 bytes.
111
123
}
112
124
```
113
125
114
126
By default the file will be downloaded in the native format. You can request that the server convert the file to PDF prior to conversion by setting the `fileFormat` in the `Download` methods:
115
127
116
128
```csharp
117
129
// It is assumed that objectFile and vault are already available/populated.
0 commit comments