Reputation: 1
I want to upload a file to iCloud Drive to make it public. I can already write files to the directory, but I want to make that file shareable. In the documentation I should use the setUbiquitous function to do so. However, whenever I use these functions (I've tried upload and getUrlForPublishingUbiquitousItem), I get errors like this: { code: ERR_SET_UB, message: "The file "filename.txt" couldn't be opened", domain: "", userInfo: {}, nativeStackIOS: ["0AppName0x00000000000102d4938RCTJSErrorFromCodeMessageAndNSError + 112", "" ... }
PS: I can open file from the finder
import {
defaultICloudContainerPath,
isICloudAvailable,
readDir,
writeFile,
setUbiquitous,
stat,
} from "react-native-cloud-store";
try {
setIsCreating(true);
const [date, details] = new Date().toISOString().split("T");
const fileName = `filename.txt`;
const finalPath = currPath
? `${defaultICloudContainerPath}${currPath}/${fileName}`
: `${defaultICloudContainerPath}/${fileName}`;
await writeFile(finalPath, "Hello world");
await setUbiquitous(true, finalPath, "/"); // error on this line
setFiles([...files, shorterPath(finalPath)]);
} catch (err) {
console.log(err);
Alert.alert(JSON.stringify(err));
} finally {
setIsCreating(false);
}
Should work but gives me an error.
Upvotes: 0
Views: 139