File upload 应用程序用户如何将数据保存到自己的云存储中?

File upload 应用程序用户如何将数据保存到自己的云存储中?,file-upload,cloud,storage,codenameone,File Upload,Cloud,Storage,Codenameone,在我的cn1应用程序中,我希望用户能够备份自己的云存储。例如,您自己的Dropbox帐户 我在网上寻找解决方案。我想我发现的(dropbox codenameone sdk)我只能管理一个已知的帐户,因为我需要了解ConsumerCret和consumerKey。当我编写代码时,我不知道实际的用户帐户信息。 基于其他应用程序的操作,我假设我必须登录到实际用户的帐户(例如Dropbox) 请帮助我如何调用API。使用Display中的共享API。您可以使用zip cn1lib压缩数据并将其保存在文

在我的cn1应用程序中,我希望用户能够备份自己的云存储。例如,您自己的Dropbox帐户

我在网上寻找解决方案。我想我发现的(dropbox codenameone sdk)我只能管理一个已知的帐户,因为我需要了解ConsumerCret和consumerKey。当我编写代码时,我不知道实际的用户帐户信息。 基于其他应用程序的操作,我假设我必须登录到实际用户的帐户(例如Dropbox)


请帮助我如何调用API。使用Display中的共享API。您可以使用zip cn1lib压缩数据并将其保存在文件系统中的文件中,然后使用共享API让用户选择一个本机应用程序与之共享。在模拟器上,它将有电子邮件/facebook等选项,但在设备上,您应该有更多选项。

我认为我正确地使用了API。尽管我没有正确设置手机上的文件访问权限

但是,错误发生在模拟器中

我的android手机上的邮件和DropBox共享成功。 我不喜欢这个文件有前缀(IMG_20200112_204126_)。我能换这个吗

我包括截图和代码片段

最好的问候,佩特


}

非常感谢您的建议。这个机会没有引起我的注意。现在很明显了。嗨,我如何共享不同于图像的文件类型?不管我设置了什么mime类型,模拟器都将其视为图像。在Android手机上,文件名以前缀(IMG_……)附加到邮件或发送到DropBox。因此,无法找到该文件。请帮助。本机设备的行为与模拟器非常不同。你需要在那里使用API。嗨,我不能附加图像和片段作为注释。请阅读我下面的答案。模拟器假设正确的图像,但在那里失败,但由于它在设备上工作,我没有看到问题?仅供参考,您需要编辑问题,而不是添加答案。
public ShareForm(Resources resourceObjectInstance, Form parentForm) {
this.parentForm = parentForm; 
this.theme = resourceObjectInstance;

Layout layout = new BoxLayout(BoxLayout.Y_AXIS);
setLayout(layout);

getToolbar().setBackCommand("", e -> {
    this.parentForm.showBack();
});

/* file exist on simulator */
/*        String filePath = FileSystemStorage.getInstance().getAppHomePath() + "temp/vendeg_201807011754.json"; */
/* file exist on phone */
String filePath = "file:///storage/emulated/0/Download/stratos.pdf";

String mimeType = "application/octet-stream";

boolean exist = FileSystemStorage.getInstance().exists(filePath);
long size = FileSystemStorage.getInstance().getLength(filePath);

SpanLabel spanLabel0 = new SpanLabel("File path: " + filePath);
SpanLabel spanLabel1 = new SpanLabel("File exist: " + exist);
SpanLabel spanLabel2 = new SpanLabel("File size: " + size);

ShareButton shareButton = new ShareButton();
shareButton.setText("Share data (ShareButton)");
shareButton.addActionListener(e-> {
    shareButton.setImageToShare(filePath, mimeType);
    shareButton.actionPerformed(e);
});


Button shareButton1 = new Button("Share data (Share API in Display)");
FontImage.setMaterialIcon(shareButton1, FontImage.MATERIAL_SHARE);
shareButton1.addActionListener(e -> {
    Display.getInstance().share(null, filePath, mimeType, shareButton1.getBounds(new Rectangle()));
});

addComponent(spanLabel0);
addComponent(spanLabel1);
addComponent(spanLabel2);
addComponent(shareButton);
addComponent(shareButton1);