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: ej2-vue/file-manager/how-to/pass-custom-value-to-server.md
+24-83Lines changed: 24 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,19 @@ domainurl: ##DomainURL##
10
10
11
11
# Pass custom value to server in Vue File Manager component
12
12
13
-
The Syncfusion Vue File Manager component allows you to pass custom values from the client to the server for various operations. This guide demonstrates how to implement this functionality for **Upload**, **Download**, and **GetImage** operations using the [`beforeSend`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforesend), [`beforeDownload`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforedownload), and [`beforeImageLoad`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforeimageload) events respectively.
13
+
The Syncfusion Vue File Manager component allows seamless back-end server interaction by passing custom values. This enhances the functionality and security of file operations, particularly helpful for tasks like authentication, logging, or user role-based processing. In multi-user systems, it ensures file access permissions and actions are user-specific and secure. You can manage user-specific operations such as **Read**, **Delete**, **Rename**, **Create**, **Move**, **Copy**, **Details**, **Search**, **Upload**, **Download**, and **GetImage** using custom headers or query parameters. This guide demonstrates implementing these features using the [`beforeSend`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforesend), [`beforeDownload`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforedownload) and [`beforeImageLoad`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforeimageload) events. Let's explore how to achieve this in [`Physical file system provider`](https://github.com/SyncfusionExamples/ej2-aspcore-file-provider).
14
14
15
-
## Upload Operation
15
+
## 1. Setting up the File Manager and provider
16
16
17
-
To pass custom values during the upload operation, utilize the [`beforeSend`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforesend) event of the File Manager component.
17
+
To create a basic File Manager component, start by following the easy steps in the [`Getting Started`](https://ej2.syncfusion.com/vue/documentation/file-manager/getting-started) guide. This will allow you to manage files and folders on your system, whether they are stored physically or in the cloud.
18
18
19
-
### Client-side Implementation
19
+
For connecting the File Manager to a physical file system, check out the [`Physical file provider`](https://ej2.syncfusion.com/vue/documentation/file-manager/file-system-provider#physical-file-system-provider) section. This part of the documentation will help you configure it correctly.
20
+
21
+
## 2. Handling File Operations
22
+
23
+
After setting the File Manager component with the physical file system provider, you can handle file operations by passing custom values to the server. To pass custom values during the **Read**, **Delete**, **Rename**, **Create**, **Move**, **Copy**, **Details**, **Search** and **Upload** operations, utilize the [`beforeSend`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforesend) event of the File Manager component. This event allows you to modify the request before it is sent to the server. You can add custom headers to the request to pass additional information to the server.
24
+
25
+
The `onBeforeSend` function is designed to enhance security by adding an authorization header to every outgoing AJAX request. Before a request is sent, this function is called, and it attaches the **Authorization** header with the value **User1** to the request. This ensures that the server can verify the request's authenticity and handle it accordingly.
20
26
21
27
```ts
22
28
@@ -59,7 +65,7 @@ export default {
59
65
60
66
```
61
67
62
-
### Server-side Implementation (C#)
68
+
In server-side, `FileOperations` and `Upload` methods access the **Authorization** header from the incoming HTTP request and perform the necessary operations.
63
69
64
70
```typescript
65
71
@@ -70,8 +76,6 @@ public class FileManagerController : Controller
@@ -87,11 +91,10 @@ public class FileManagerController : Controller
87
91
88
92
89
93
```
90
-
## Download Operation
91
-
For the download operation, use the [`beforeDownload`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforedownload) event to send custom values to the server.
92
94
93
-
### Client-side Implementation
95
+
##3. Handling Download Operation
94
96
97
+
For the **download** operation, use the [`beforeDownload`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforedownload) event, setting [`useFormPost`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/beforeDownloadEventArgs/#useformpost) as false to use a fetch request to send the custom header in **beforeSend** event. Here an **Authorization** header is appended to fetch request headers with the value **User1**.
var header =HttpContext.Request.Headers["Authorization"];
189
148
...
190
149
}
191
150
192
151
```
193
152
194
-
## GetImage Operation
195
-
196
-
For the GetImage operation, use the [`beforeImageLoad`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforeimageload) event to pass custom values as query parameters.
153
+
## 4. For GetImage Operation
197
154
198
-
### Client-side Implementation
155
+
For the **GetImage** operation, use the [`beforeImageLoad`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/#beforeimageload) event to pass custom value. Since the **GetImage** operation doesn't support custom headers in HTTP requests, pass the custom values along with [`imageUrl`](https://ej2.syncfusion.com/vue/documentation/api/file-manager/beforeImageLoadEventArgs/#imageurl) using query parameters instead.
199
156
200
157
```ts
201
158
@@ -234,7 +191,7 @@ export default {
234
191
235
192
```
236
193
237
-
### Server-side Implementation (C#)
194
+
In server-side, you can able to get the custom query parameter value using **Authorization** in `GetImage` method. To get the custom query parameter value, extend the `FileManagerDirectoryContent` class and add the custom property **Authorization**.
238
195
239
196
```typescript
240
197
@@ -261,22 +218,6 @@ public class FileManagerAccessController : Controller
261
218
262
219
```
263
220
264
-
## Implementing custom value transfer in Syncfusion File Manager with server-side integration.
265
-
266
-
The below file system provider allows the users to access and manage the file system which includes the server side code for custom values passing from client. To get started, clone the [provider](https://github.com/SyncfusionExamples/How-to-pass-custom-values-from-client-to-server-in-filemanager) using the following command.
After cloning, just open the project in Visual Studio and restore the NuGet packages. The root directory of the provided file system in the File Manager controller is **Files** for **User1**. Now, just build and run the project.
221
+
> **Note:** View the complete [Github sample](https://github.com/SyncfusionExamples/How-to-pass-custom-values-from-client-to-server-in-filemanager) which includes all the above event along with service code for passing custom values to server.
275
222
276
-
Run the sample which includes all the above event for passing custom values to server: [How-to-pass-custom-values-from-client-to-server-in-File-Manager](https://stackblitz.com/edit/custom-values-from-client-to-server-in-vue-filemanager?file=src%2FApp.vue)
277
-
278
-
```ts
279
-
url: "http://localhost:{port}/api/FileManager/FileOperations", // Replace {port} with host wherever used.
280
-
```
281
223
282
-
The project will be hosted and map the local host in the **ajaxSettings** property of the File Manager component.
Copy file name to clipboardExpand all lines: ej2-vue/file-manager/upload.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,10 +124,10 @@ If you want to allow only image files like .jpg and .png, you would set the prop
124
124
125
125
The File Manager component provides support for external drag-and-drop functionality for uploading files by dragging it from local file system to File Manager.
126
126
127
-
Setting [allowDragAndDrop](https://ej2.syncfusion.com/vue/documentation/api/file-manager#allowdraganddrop) property to false will not prevent the file upload operation through external drag and drop. It will only prevent drag and drop action within the File Manager component
128
-
129
127
To completely prevent the external drag-and-drop upload functionality (i.e., disallowing users from dragging and dropping files from outside into the File Manager), you can set the [dropArea](https://ej2.syncfusion.com/vue/documentation/api/uploader#droparea) property to null. This can be done by accessing the File Manager instance via its class methods.
130
128
129
+
>**Note:** Setting [allowDragAndDrop](https://ej2.syncfusion.com/vue/documentation/api/file-manager#allowdraganddrop) property to false will not prevent the file upload operation through external drag and drop. It will only prevent drag and drop action within the File Manager component.
130
+
131
131
The following example demonstrates how to prevent the external drag and drop upload actions for all types of files in the File Manager component.
0 commit comments