Sal Solis
Sal Solis

Reputation: 25

Tizen can not create or find directory

For about a month now I've been trying to create a directory to save images to on my tizen web app for my Samsung Watch, but nothing has worked. Below are the snipets of code that I've tried on tizen's web simulator and on my watch:

var success = function(dir) {

    dir.createDirectory('AFG');
    alert('yay');
};

var error = function(e) {
    alert('Error: ' + e.message);
};

tizen.filesystem.resolve('images', success, error);

Result:

On web simulator: 'newDir' folder nowhere to be found.

On watch : Error: Platform Error.

var successCallback = function(newPath) {
    alert('New directory has been created: ' + newPath);
};
var errorCallback = function(error) {
    alert(error);
};
tizen.filesystem.createDirectory('images/newDir', successCallback, errorCallback);

Result:

On web simulator:

Uncaught TypeError: tizen.filesystem.createDirectory is not a function
    at HTMLAnchorElement.<anonymous> (add.js:73)
    at _raiseTouchEvent (ripple.js:155080)
(anonymous) @ add.js:73
_raiseTouchEvent @ ripple.js:155080

On watch: No feedback and no 'newDir' folder created in opt/usr/media/Images

Note: I have both privileges enabled:

http://tizen.org/privilege/filesystem.write

http://tizen.org/privilege/filesystem.read

Any help would be greatly appreciated. Thanks!

Upvotes: 1

Views: 703

Answers (2)

15kokos
15kokos

Reputation: 698

Accepted answer is a workaround for the real problem, which is caused by new privacy policy introduced since Tizen 4.0 (this causes that the behaviour differs depending on versions). You can check the details in this answer: https://stackoverflow.com/a/57475526/11502478

Accessing filesystem is also privacy related the same way as location. First you need to ask application user for permission to access filesystem. Then the application would work as expected.

Upvotes: 0

UkFLSUI
UkFLSUI

Reputation: 5672

Your first code snippet is correct and it is supposed to create the directory:

var success = function(dir) {
    dir.createDirectory('AFG');
    alert('yay');
};
var error = function(e) {
    alert('Error: ' + e.message);
};
tizen.filesystem.resolve('images', success, error);

You should find the newly created directory in this location: /opt/usr/media/Images/

Upvotes: 1

Related Questions