[英]Appcelerator Titanium - how to back up database to cloud (Android)?
[英]Appcelerator Titanium Cloud - How to overwrite existing file copy on cloud?
我有以下代碼將數據庫上傳到Titanium Cloud:
Cloud.Files.create({
name : dbName,
file : dbFile
}, function(e) {
if (e.success) {
var file = e.files[0];
alert('Boats successfully backed up to cloud!');
} else {
alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
}
});
但是,如果數據庫已保存一次以上,它將在舊副本旁邊上載另一個副本。 我只想在雲上有一個數據庫副本。 我知道有方法Cloud.Files.remove
和Cloud.Files.update
,我想使用其中一種方法在雲上為我的數據庫的每個用戶保留一個副本。 但是,它們的值稱為file_id
。 這個值是什么,應該是什么?
您應該使用Cloud.Files.query()
檢查文件是否已經存在,然后根據結果使用Cloud.Files.create()
或Cloud.Files.update()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.