2016년 12월 4일 일요일

File Extension - Copy problem


Im using Taifuns File Extension to copy files from one directory to another and Im running into a wall.

Ive tested it out and I am able to copy to the folders just fine, but now that im trying to add it to the working app I get "cant copy directory" error messages.

I have a contact app that holds info and 2 photos. Im working on an export and import feature in order to share contacts with others with the app.

I can export just fine.  Everything goes to a csv and reimports just fine.  But the pictures are giving me a headache.

The Pictures are saved as file paths in the csv.  The file path directs it to the /storage/emulated/0/Pictures/_app_inventor_image_picker/ folder.

The app uses an image picker for choosing the photo and saves a copy in the above folder with a new name.

My export uses a share (3 actually) one shares the csv. the other 2 shares the images from the above folder holding on to their new name.  The orignal picture is not in service and is not exported.

When the user recieves the emails containing the files they simply save them to the download folder and the app imports them from that folder is this fashion:

The CSV has a name, that name is entered in the import textbox and the csv is imported into the app and populates the boxes.  Within that csv is the path to the photos.
I have 2 labels set up to display the path and file name of each photo.  The Import looks at those labels and continues to copy the files from downloads to /storage/emulated/0/Pictures/_app_inventor_image_picker/.


Except, I get a Sorry,cant copy a directory.

If I hard code the file and path like the copy block that is not attached in the image above, it copys just fine.

when I try to join text in order to keep the paths the same, but make the file name change based on the info in the csv, I get the error.

I have used the File Exists block and it shows true.

Ive tried using replace block, as shown, to get rid of the file path and only display the file. So I can use that to copy, doesnt work.

Ive tried using split, and Segment Text.  That seemed to work,  But the file path is always 56 characters. fine.  The file name, is 19-20 characters. depending on the file.  So It throws and error saying the files too long.
Is there a way to use the segment text block and say :start-56,  length - open or count how many spaces in that file name?

Ive also cleared out the test phone and dumped the cache several times in order to see it clean.  

Any ideas?

-- 
use Do it to debug your blocks, see also tip 4 here

Top 5 Tips: How to learn App Inventor


 I get a Sorry,cant copy a directory.

you only can copy files and not directories


-- 
use Do it to debug your blocks, see also tip 4 here
Top 5 Tips: How to learn App Inventor

 I get a Sorry, cant copy a directory.

you only can copy files and not directories


Refer to my previous: Im using Taifuns File Extension to copy files from one directory to another and Im running into a wall.

Im only trying to copy a csv, a jpeg, and a jpeg from the Downloads folder to the /Pictures/_app_inventor_image_picker/.

Ive tried the do it and something interesting has happened.

I attached the blocks to the import button.  When the button is pushed it checks to see if the txtbox has a name to import then sees if the file is in the download
folder, if it is it Reads from that file into the app and saves. - this works.
When I add the copy from this same directory it gives the error of Sorry cant copy a directory.

Heres the weird part.   If I click do it on the copy block- it works.

If i move the copy block to the Got Text block - It works (except it doesnt display the photo until you go to the list picker and pick that name - refreshing the contact.)

It only throws the error if the copy is in the same blocks as the read from the csv (which I need to do first in order to get the filename of the images)

When you made the extension is there a limitation that says can only do one thing?  Read or copy? Not both?

-- 

If i move the copy block to the Got Text block - It works 

it seems to be, you have a timing issue? unfrotunately I can't find that event in your screenshot?
also you renamed the components, which makes it hard to understand your blocks...
you are using the web component, correct? the web component works asynchronously, which means you only can do something with the file after having received it and not earlier
for example first download the file, then receive it and then copy it to somewhere

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

-- 
Your exactly right,

Ive been playing with it and it has to load the csv into the app first, then it can copy the files.

Ive been trying to work on the timing in order for the picture to populate when the fields do.  A timer works, but doesnt populate the images until after I go to the list picker and choose the new entry.

Im trying to put a loop in the import of a second or so to see if that works.

Is there a way to 'refresh' a listpicker?  Can I tell it to open the listpicker and choose the same file that was imported?  (the name of the import is not always the name of the listpicker.)

thereby 'refreshing' that record and displaying the images?

-- 
don't use a timer, see this example how to download some files asynchronously https://puravidaapps.com/filebyfile.php


Is there a way to 'refresh' a listpicker?  Can I tell it to open the listpicker and choose the same file that was imported?

???
sorry, I don't understand, you might want to elaborate
you always can assign a new list to the listpicker elements property and to open a listpicker use the open method
Taifun

-- 
Ok, Got it working.

Your right, it was a timing issue. I put the copy blocks on the import got text block and the only thing I could do was to call OPEN Listpicker after it imported

This added it to the list where I could choose it again and see all the information.

I was hoping I could simulate a screen refresh (not really but the end result would be the same).

After the import occurred, I tried programmatically open the listpicker and choose the recently imported contact.
Giving the effect that the import occurred and your seeing what you just imported. (refresh)

Still working on the refresh... Thanks for the Help!

-- 


댓글 없음:

댓글 쓰기