removing downloaded images when RestKit delete Objects - restkit-0.20

I want RestKit to automatically download object's image property (i.e my site.com/images/photo01.jpg) and when removing that object after syncing with server delete its downloaded images.
an example:
product
{
name:product1,
image:www.mysite.com/images/photo01.jpg
}
after syncing with core data
product
{
name:product1,
image: /documents/photo01.jpg
}
here I want RestKit automatically download the image and assign local path as product image property.
and after syncing with server if I have deleted that object on the server, RestKit delete that image file in the local store too.
is that possible? How can I achieve this?

Related

Upload webscrapped images from folder to database Django

I'm webscrapping data about ski resorts from a site, also getting some pictures. I am saving those pictures in a folder and after that i'm getting them in SQLite database through an imageField.
The bad part is that they don't work
directory = r'C:\Users\tiberiu.ghimbas\Documents\Resorts img5'
image_list = [cv2.imread(file) for file in
glob.glob(r'C:/Users/tiberiu.ghimbas/Documents/Resorts img5/*.png')]
This list is then looped and insertet item by item.
I'm doing all the correct settings for handling images and media files.
I know that by going the classic way of uploading images through a form will get you in the database the path to the image from de media/"upload_to = 'filename'" folder but going by my way i'm getting only them image name.
How can i solve that ?

Moving uploaded files in Socialengine

I tried moving uploaded file through browse action in socialengine from /public/user/ to /Files/SE/ by using
1.
$fileobj = new Zend_Cloud_StorageService_Adapter_FileSystem();
$fileobj->moveItem($sourcePath, $destinationpath);
move_uploaded_file($sourcePath, $destinationpath);
Both of these couldn't move the file. I have checked the paths too they are perfect and works with other frameworks
You should use API of Storage module which will allow you to create temporary files (when you need to resize images or convert videos) and then place them into public storage. This files will be tracked in engine4_storage_files table.
I got it worked by using createSystemFile() function under storage > Model > DbTable > Files.php
I created a function similar to this and gave parent_type as the folder which I wanted to move in the files.

NSCoding Prebundle Data

I am using NSCoding to save a serialized list of my object. This object's successfully saved in the path:
/var/mobile/Applications/F923C87-360D-4B429-B2E9-CAE121009ECE5/Documents/feed_file
And I can get the object successfully when the app starts.
I'm looking to deploy the app with some contents already loaded, so I want to have a primary version of feed_file in the apps.
How can I do that, copy it the first time the app starts but not the other times?
Put a bit of code in applicationDidFinishLaunching:, check whether there is any file at the destination path (Documents/feed_file), if there isn't then copy the default file out of the bundle. The default file should be part of the Xcode project and copied to the bundle during the build.

Save the modified Property file inside WAR deployed on server

We are trying to use Apache PropertiesConfiguration in our project using JSF and JBoss.
My property file is located inside a package say demo.prop by the name of Prop1.prop
Inside my WAR file the same is present under /WEB-INF/classes/demo/prop/Prop1.prop
Using
FacesContext.getCurrentInstance().getExternalContext().getResource("/WEB-INF/classes/demo/prop/Prop1.prop");
I am able to fetch the property file. So when I try to extract a string from the property file using
PropertiesConfiguration pc1=new PropertiesConfiguration(a);
String s1=(String)pc1.getProperty("User_Name");
I am able to get the proper string. Using set property method I am able to set the property also.
pc1.setProperty("User_Name", "hardcodedString");
But I am not able to save the FILE back to this location. No matter what I do it is not able to save the file using pc1.save.
Can anyone please try to tell me how can I save this file back to its original location so that the changes done in the property file remain as it is.
Modifying the WAR file is a bad idea (for example, some web servers may notice the file
modification an redeploy your app, there may be problems when the server explodes the war on deployment etc.)
I would suggest applying an alternative approach - some possibilities are:
Place the properties in a database table, so they can be easily modified
Use an external properties file for overriding your "Prop1.prop" file settings. You can pull this off for example as follows. Assume that the default property values are bundled in your WAR and the modified values are saved to some other path, which is defined using a system property - let say it's called CONFIG_LOCATION. Now after loading your properties from the bundle you read them also from this external "overrides.prop" file - this overrides your defaults from "Prop1.prop":
PropertiesConfiguration pc1=new PropertiesConfiguration(a);
try(FileReader propReader = new FileReader(System.getenv().get("CONFIG_FILES") +"/overrides.prop"){
pc1.load(propReader);
}
When you need to save changes, you do that to "overrides.prop" - this will save all
the properties, not only the changed ones, but that should have no negative effects.

Capture and save a photo in XAML/C# for a Windows store application

I'm trying to take and save a photo using a windows surface device.
I'm using the code below to take a photo and this work but I'd like to automatically create a directory on the device's local drive and save this photo there without any dialog prompts.
So the code I use to capture to photo is as follows:
CameraCaptureUI camera = new CameraCaptureUI();
StorageFile file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (file!=null)
{
using (IRandomAccessStream ras=await file.OpenAsync(FileAccessMode.Read))
{
BitmapImage source = new BitmapImage();
source.SetSource(ras);
imageBuildingPhoto.Source = source; // this is just an image control.
}
}
So after this I'd like to automatically save the photo to a new directory. e.g.
My Pictures\NewDirectory\Photo1.jpg
Anybody got any idea how I can do this?
This is a windows store application written using C#4.5 and XAML.
Thanks in advance
Use the CopyAsync method on the StorageFile object you get back (file). You can specify a directory and file name. If you need to create your own directory structure, you will need to enable access to the appropriate library in the Package Manifest then create it in code. You will then use the StorageFolder class and its CreateFolderAsync method to create folders.
http://aka.ms/30Days has some great resources for learning about scenarios like this. Might be worth checking out.
Your code will need to look to see if that folder exists and create it if it does not. Your app will need to declare the capability to access the user's Photos library in the app manifest, too.
To take a picture, your code is correct. I have a walkthrough in case you want to verify it against some other code: http://blog.jerrynixon.com/2012/10/walkthrough-capturing-photos-in-your.html
To interact with the file system, this can be tricky, but I have a longer write up on that if you want to reference it: http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html
The answer to your question is, yes you can. I have done it in my own apps. Now, it's just a matter of you implementing it in yours. You will find it to be pretty easy.