Do you want to send files to OneDrive from your K2 application? So, this article will show you how to do it, something simple 🙂
In this article, we will use OneDrive Online, please foudn below the different steps to play with OneDrive file in your K2 app.
Click on this link to download.
1. Copy the DLL
After downloading the service broker, open and copy it to the ServiceBroker folder in your K2 installation directory.
2. Creation of Service type
Once the DLL has been copied, open the SmartObject Service Tester utility, then click on the « Register ServiceType » button
- Service: Select the SendToOneDrive service
- System Name: you can leave the default name or change it
- Guid : let it by default
- Click on « Add »
3. Creation of Service Instance
Once the « Add » button has been clicked, a new service type appears, you must create an instance of this service (right click, then Register Service Instance)
- Authentication Mode : you are asked for the authentication mode choose static
- User Name, Password: enter the email and password of your account with which you log in to OneDrive
- Click on Next to continue
- Fill the Sytem Name and Display Name of your instance service, then click on Add
4. Creation of SmartObject
- Generate a SmartObject by right-clicking on the «Smo SentToOnedrive» service and then «Create SmartObject»
- In the «Name» field, enter a name or leave the default name
- In the «Category» area, select the category where your SmartObject will be placed (usually the SmartObject folder of your K2 Application): In our case, we leave in the default category
Then click on «Publish SmartObject»
Running the SmartObject
We will now test our SmartObject, it will be a question of sending a file to this library. It can be put either directly or in a folder.
1. Creating a folder in OneDrive
Go to the «SmartObject Explorer», section, then go to the category where you published your SmartObject ( in this case “default”), then right-click on the created SmartObject and choose « Execute SmartObject » . Choose OneDrive create folder method.
- Url Site : is the address of the site
- Folder Name : enter the name of the folder
- OneDrive Library : enter the library in which you want to create your folder
then click on Execute
2. Upload a file to OneDrive
Change the method and choose the Upload To OneDrive method.
- Full File Path : enter the full path to your file
- Name folder : if you want to put it in a folder, fill in the name of the folder and do not put anything else. NB: the folder to be filled in must be an existing folder
- Select File : you can also attach the file by clicking on the Add button on the right
And if on the other hand you want to put it in a folder, let’s take the case of the folder “Mon Dossier”, also fill in the name of the folder at Folder Name level and execute 🙂
You can now use this SmartObject in your K2 application.
See you later 😉