So I have to manage temp files inside the app.
Otherwise,
is there any chance that the sendMessage method returns after having
effectively transferred the file
instead of being that the email app just shows it as an attachment (to be
loaded after the user hits the send button),
so
it can be deleted immediately after the method returns?
Or is there any way to understand that the user has completed that
operation? (Or just it leaved the email app back to my app)
Maybe the onStart method is called? Isn't it?
I mean, even it the email app would load the file when the user hits the
"send" button, I can assume that if the user comes back to the app, the
temp file can be deleted.
Thanks in advance
Il giorno lunedì 21 dicembre 2020 alle 03:09:03 UTC+1 Shai Almog ha scritto:
> You will have a strange long string usually with a long number in the
> middle.
>
> On Sunday, December 20, 2020 at 4:22:54 PM UTC+2 P5music wrote:
>
>> I see. I would like to know what form has the real name of the temp file,
>> if you have seen it sometimes.
>> I could use this instruction:
>> file=File.createTempFile(fileName"+"_",".ext");
>> to have something resembling a user-created file name. It will have a
>> strange string in the middle I suppose, like:
>> myfilename_vjh4v444vjhv4j45445h4j5.ext
>> Is it right?
>> Regards
>>
>> Il giorno domenica 20 dicembre 2020 alle 02:58:03 UTC+1 Shai Almog ha
>> scritto:
>>
>>> There's a minimum length to the temp file prefix/sufix. As far as I
>>> recall you can't create the file with blank prefix/suffix but I might be
>>> wrong.
>>>
>>> It very likely won't work and I would avoid mixing temp files and
>>> regular files. Temp files can reside on a different volume and renaming
>>> them to a regular file might not work.
>>>
>>> On Saturday, December 19, 2020 at 5:20:09 PM UTC+2 P5music wrote:
>>>
>>>> Is this going to be working as described?
>>>> ....
>>>> ....
>>>> try {
>>>> file=File.createTempFile("","");
>>>> String
>>>> path=file.getAbsolutePath().substring(0,file.getAbsolutePath().lastIndexOf("/"));
>>>> File oldFile=new File(path+"/"+fileName+".ext");
>>>> if (oldFile.exists()) {
>>>> oldFile.delete();
>>>> file=File.createTempFile("","");
>>>> }
>>>>
>>>> file.renameTo(oldFile);
>>>>
>>>> OutputStream os = Storage.getInstance
>>>> ().createOutputStream(file.getAbsolutePath());
>>>> ....
>>>> ....
>>>> Il giorno sabato 19 dicembre 2020 alle 06:54:54 UTC+1 Shai Almog ha
>>>> scritto:
>>>>
>>>>> Yes but then you might as well just create a non-temporary file with a
>>>>> specific name and clear it when the app exits or periodically. You can
>>>>> create a folder to store these files and wipe it occasionally.
>>>>>
>>>>> On Friday, December 18, 2020 at 10:47:40 AM UTC+2 P5music wrote:
>>>>>
>>>>>> Ok
>>>>>> Can the temporary file be renamed with the entered filename? This is
>>>>>> for the user to see and attach a file with a meaningful name.
>>>>>> Thanks
>>>>>>
>>>>>> Il giorno venerdì 18 dicembre 2020 alle 05:53:46 UTC+1 Shai Almog ha
>>>>>> scritto:
>>>>>>
>>>>>>> No. That's not a file name. That's a prefix and suffix. The actual
>>>>>>> name would be longer.
>>>>>>>
>>>>>>> On Thursday, December 17, 2020 at 11:06:00 AM UTC+2 P5music wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> I want to know whether the creation of a temp file with that method
>>>>>>>> will give an error if the file already exists with that file name.
>>>>>>>> I think that the file name is not random because it is a parameter
>>>>>>>> of the createTempFile method, is it?
>>>>>>>>
>>>>>>>> Il giorno giovedì 17 dicembre 2020 alle 04:35:55 UTC+1 Shai Almog
>>>>>>>> ha scritto:
>>>>>>>>
>>>>>>>>> You need to save a reference to the created temp file to check if
>>>>>>>>> it exists as the name is random.
>>>>>>>>>
>>>>>>>>> On Wednesday, December 16, 2020 at 12:52:09 PM UTC+2 P5music wrote:
>>>>>>>>>
>>>>>>>>>> Maybe what I am saying does not make sense, but if I create the
>>>>>>>>>> temp file I am already going to get an error if the file exists.
>>>>>>>>>> So I should use
>>>>>>>>>> file=new File(fileName+".ext");
>>>>>>>>>>
>>>>>>>>>> and then create it with
>>>>>>>>>> if (!file.exists()) file=File.createTempFile(fileName,"ext");
>>>>>>>>>> ?
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> Il giorno mercoledì 16 dicembre 2020 alle 04:45:37 UTC+1 Shai
>>>>>>>>>> Almog ha scritto:
>>>>>>>>>>
>>>>>>>>>>> I don't follow?
>>>>>>>>>>> What's the problem with exists() ?
>>>>>>>>>>>
>>>>>>>>>>> On Tuesday, December 15, 2020 at 10:41:21 AM UTC+2 P5music wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Excuse me, I have another question about this.
>>>>>>>>>>>> The app has to check if the file is already present. It could
>>>>>>>>>>>> happen when the user types the same file name before the temp
>>>>>>>>>>>> directory has
>>>>>>>>>>>> been emptied.
>>>>>>>>>>>> So I have to check it and delete before creating it again.
>>>>>>>>>>>> But I wonder if temp files are special files, how to check it
>>>>>>>>>>>> without any uncertainty?
>>>>>>>>>>>> Thanks
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Il giorno martedì 15 dicembre 2020 alle 05:16:12 UTC+1 Shai
>>>>>>>>>>>> Almog ha scritto:
>>>>>>>>>>>>
>>>>>>>>>>>>> It should. But the only way to make 100% sure is to test on
>>>>>>>>>>>>> the device.
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Monday, December 14, 2020 at 1:25:33 PM UTC+2 P5music wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> I would like to know if this code snippet will work on iOS.
>>>>>>>>>>>>>> I want to use the message send feature to export some
>>>>>>>>>>>>>> application data.
>>>>>>>>>>>>>> The user is asked for the filename, then a temporary file is
>>>>>>>>>>>>>> created containing the JSON text to be exported (with a custom
>>>>>>>>>>>>>> file
>>>>>>>>>>>>>> extension), then that file is used to create an output stream
>>>>>>>>>>>>>> and attached
>>>>>>>>>>>>>> like plain text (or should the json mimetype be used?), with no
>>>>>>>>>>>>>> subject and
>>>>>>>>>>>>>> no recipients.
>>>>>>>>>>>>>> Thanks in advance
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> try {
>>>>>>>>>>>>>> file=File.createTempFile(fileName,"ext");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> OutputStream os =
>>>>>>>>>>>>>> Storage.getInstance().createOutputStream(file.getAbsolutePath());
>>>>>>>>>>>>>> os.write(text.getBytes("UTF-8"));
>>>>>>>>>>>>>> os.flush();
>>>>>>>>>>>>>> os.close();
>>>>>>>>>>>>>> } catch (IOException e) {
>>>>>>>>>>>>>> return;
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>> Message m = new Message("");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> m.getAttachments().put(file.getAbsolutePath(), "text/plain");
>>>>>>>>>>>>>> Display.getInstance().sendMessage(new
>>>>>>>>>>>>>> String[] {""}, "", m);
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/2e3bed99-560e-417d-85a4-ca9012f734f4n%40googlegroups.com.