 session, so okay what's a file resource? A file resource is a resource that we can download through the API and it has a file. Now we only support images in the SDK but in the future we will try to support all type of files. So let's go to the SDK and now offer a module which is the file resource module and also to helpers which are the file resource directory helper which we'll talk about later and the file resource helper. This will be used to resize the images. Okay so the workflow of when we want to upload and download images will be something like that. So first of all we don't load the metadata and the file resources. So when we don't load the metadata we can ask the SDK just if we want but if your application is going to use images you will be able to through the SDK ask for the file resources that are associated to your data. So also after that we can take pictures and resize them and then we will take these pictures these files and we'll add them with an SDK repository in the file resource module that with handle the state the SDK will put the state of the file to post and next time we sync the data we will upload this picture. So this process can be a bit slow if there is like a mini pictures or your connection is not like really really good but the SDK will know when a file is uploaded or not so don't worry about that. Okay so now we entered the file resources module and we call the method download this will we will call this method after the metadata and data download and then what will the SDK download well it will download all track entity attribute values and track entity data values so for tracker and for data element whose track entity attribute type and that element type are image type so in the when you enter to maintenance you can select the type of each attribute or that element so if you select image type and you have those attributes in the in your database the SDK will download all the images so all the file resources that has not been previously downloaded. Okay so it's a bit tricky but it's just like all the attributes the type image and all the data values of type image so after that we also have in the same file resource module file resources which is another repository as all that we have seen in this repository you can get the files so you can filter and that will be used to present your pictures. Okay when you want to add a new file resource to the SDK in order to upload it you will have to use the add method here and pass the file so this method will return the UID of the file resource that we are creating and this UID will be used to update the track entity attribute value or the data value associated with the file so you will have to go to this attribute value for this track entity instance for example and set this UID so you will link the file and this attribute and when you want to show the image you will just have to to see if the track entity attribute value type if the type image and then present it in that way. For the file resources upload well you have to go again to the collection repository of the file resources and just call the upload method it's very easy so you just have to do that and it will trigger a series of calls and all the files will be shared and server so after this call you will so the SDK will provide you a new UID of this file resource that means that when you create a file resource you get a provisional UID but when you upload it to the server the server will rename this UID and get another one a new one and you will get that one and you and the SDK will automatically rename all the UIDs so the SDK will look for the track entity attribute values and the track entity data values and will update these UIDs so you don't have to do anything but just you have to know that it will happen that you have all UID and then it doesn't work anymore so you will have the new UID you have to take care of that so this is a helper that we have in the in the SDK is the file resizer helper and it has a method that is the resize file that takes a file it only takes a file of type images if it's not an image it will throw an exception but if you pass a file you will be able to resize the image to those to a small, medium, and large you have to do that before upload the images to the server because if not you can pass like really really big files and probably you want to do that because it could be like that when you try to upload the images it takes like way too long or you need a lot of space for these images so always resize the file don't forget that and the other helper for the file resources is the file resource directory helper and this helper will help you with the file directories so they have a method that will point you to the directories where you have all the files the SDK resources is one of the directories and there is where the SDK saves the files associated with the file resources so there is well actually the files will be but we also have another file another directory so another folder where you have to work always before saving the file resources so here is the place where all the files that are not there are for example the camera photos or files that you want to resize later well this is the place for that and this is the place for that because maybe you want to have like a really tidy file resource directory here where you only have the the actual resources of the pictures and here you can have like all the other things you have to take care because other applications in Android or even the user can delete these files so you have to type this catch a resource like graph will be you have to clean when you create that picture and you put it there you have to always remove this picture after you have moved this picture to the SDK resources directory so what I'm going to do exercises about this thing so don't worry we are we will be able to understand all that thing what the images so now we have this exercise and I think it's going to be a really cool exercise because it's not just about data we are working with images and that's kind of fun in our role so okay what is what we are going to do I want to try to take a picture and save this picture as the image state so now the we have a track in the instance with type person which has the name which has the last name but also have a picture so we are going to try to set this picture and create a new file using the directory helper to get the catch a file to use the to sorry to store the temporary file the temporary picture when you take the picture and after that we're going to use this picture and we are going to use the file resizer helper we're going to resize the picture and after that we are going to save the the picture with the in the SDK in the correct folder so let's go and you're going to see the exercise first of all we have the initial branch here which is the XSS9 file resources and this is the the XSS class we are going to use again the code executor activity as before this exercise is not that difficult so I hope you all can solve it kind of quick so I'm going to see you how it looks like so you have to go to the code executor activity here and here the first part of the exercise is just align where you have to use the file resource directory helper and get the catch resource directory so you have to create a new file so you have to use the new file and then use the the directory helper so if you come here to file in the constructor you see that you have to pass the pattern which is the file and the string for the for the path so you have to pass the path and you for that you will use directory helper and after that you are going to have to insert the file to an attribute and here are all the instructions and you can do it here after this line so you are going to use this track entity instance that use this method that is like the same that we have done before so it just create a track entity instance and give it to you and then this method is this other one that you just created so first of all you have to fill this one and then you will get the file so after that you have to take care about the file you have to check if the picture exists and if it exists resize them then use the module the file resource module to add the file after that you have to add the resource to an attribute and you can use the attribute helper which is this class that we have here you can call the TA image and you will get the UID of the attribute okay so you will have to do something like that attribute helper the image and then you pass the track entity instance and you will get the the attribute of this for the picture after that you have to come here come to the code execute executor execute the code and then you can go to your track entity instances and you will see here another a new track entity instance with a picture just like this one so first of all do you have any questions okay I think there's no no questions now so okay well so now we are gonna take a bit about tracker data upload and error marksman so all the data that today we have been learning how to create you're gonna try to upload it so we're gonna talk about that upload like a bulk upload then granular scene where we are gonna just upload granular data and then the error marksman so first of all the track entity instance and event repositories here we have an upload method and this method will be used to upload track entity instances and events without registrations also you can use some filters to filtering this track entity instances uploads just to upload the track entity instances or events that you want also as a remember the instances whose state is different to post or to update they are not going to be updated so as a remember I just put here this slide from yesterday so if you want to call upload and you want these track entities to be uploaded they have to have these two states if they are synced they are not going to be uploaded also if they have error or warnings they are not to be uploaded either so you have to make some changes here to get to change the state to update then you will be able to upload the data again so what happened when you update the data so if you have a method if the data is to post to update and you have a success when you update the data then they are gonna change to sync if it is to delete and you success then you are gonna delete the entity in your device so it will be it won't be in your device anymore but if you have an error and is any of these three states you are gonna get an error or a warning depends on the type of error you are getting so so for the granular thing you can add the filters that you want but one of the typical filters that you have is filtering by the uid so if you filter by the uid and then you call the upload method you are gonna filter a concretely a track entity instance so you can add more filters if you want and for the conflict resolution because maybe if when you try to upload some data you can get an error from the server and in case there is any error in the upload the sdk will make two things will create a record in the table tracking to the import conflict but it also will mark the ti or the enrollments or the events with the errors or the warnings so we change the state of these entities and also the track entity import conflicts for a ti or an event are removed if then you create a successful sync of this element so maybe you have some track entity import conflicts and they're still there but you make some changes and then you update this elements again and they are succeeded in this updated so the sdk will remove the tracking in import conflicts so here is an example of how the sdk will propagate upwards the response you have this ti with an enrollment and also with an event all of them are from the ti and you upload this whole thing to the to the server so then the server response and okay the ti wasn't didn't have any conflicts so okay then we can read the enrollment and response of the server and if it is accessed will mark the enrollment again as a success so a sync but if we check the event and for example we find some errors in the event then we will mark again the enrollment and the ti with an error so if the ti that has an event has an error at the end will have an error too and the enrollment will mark with an error so the states of the ti the enrollment and event will be error in case that there is a warning it will be the same but with warnings the tracker import conflict is an object that will help you to to see where the conflicts are so its object will have a conflict with the which is the conflict description the uid of the order the uid of the tracking to the instance the uid of the enrollment the uid of the event all of them if any so if there is not a targeted instance or enrollment in your post that they will they wouldn't be here you will find another also for the tracking to the attribute or that that element a uid the table reference is if for example if it is a ti or it's an enrollment or it's an event it will be marked here also you will have an error code that gsdk will write here the status if it's a warning or an error the created date or the description and with the description of the conflict and for example in this case the data element you can try to find the data element with the error and mark it in the form for example and also here you can use the description to see what's happened here okay that's all the theoretical part and now we are going to go with a simple exercises about this so what we have to do is implement the upload logic so there's two exercises the first of them is a bulk upload where you have to trigger the upload for targeted instances events aggregated data and file resources so the all the the data that we have and we can use flipper to inspect the post call and see that we are really uploading all the files so you can make some changes in attracting the instance or an event or in related data even some resort file resources and then try to inspect the post and see that they are uploading so you can after that login in the in our url and check that the data that you have uploaded have been created in the in the server for that you have this initial branch here which is the exercise 10 a bulk data upload and the exercise classes in this case is only the main activity for the second exercise we just want to upload one single ti so you are going to try to use the upload method which is in the tracking the instance repository and then filter by uid also you can use flipper and check that the tracking the instance has been created and upload for that exercise you have all the information in about here so it's the the branch exercise 10 and the brand and the exercise is here I just repost this first branch the exercise 10 a so if you engage you didn't find this one you just have to go and fetch the data so you can come here give us those git and fetch again if you fetch again you will find here the the bulk data branch so after that I'm going to show you a bit in the exercise the main activity so here the exercise is to change this observable and make the calls here also you can concat concat in these calls using concat with okay and for the other exercise you will have to switch the branch and go to the the the instance adapter so I'm going to do that sorry I was freaking out then is this one no the bad one and be here so sorry and so it's in the track entity instance adapter I think yeah so here is the exercise so you have to change this observable and use this a track entity instance uid to filter the upload in the track entity instance repository this one is like very very simple the other one could take five minutes maximum so we are going to leave you 20 minutes for both exercises and if you get stuck with the branch thing just tell me and I will help you to find this branch yep do you have any question