2

我正在尝试将一些存储数据插入到 Bluemix 中,我搜索了许多 wiki 页面,但我无法得出结论如何继续。那么谁能告诉我如何通过任何语言代码(Java、Node.js)将图像、文件存储在 Bluemix 的存储中?

4

6 回答 6

3

假设您使用 Bluemix 编写 Cloud Foundry 应用程序,另一个选项是sshfs. 在您的应用程序启动时,您可以使用 sshfs 创建与作为本地目录挂载的远程服务器的连接。例如,您可以创建一个./data指向远程 SSH 服务器并为您的应用程序提供持久存储位置的目录。

这是一篇博客文章,解释了这个策略是如何工作的,还有一个源代码库显示它用于在 Cloud Foundry 应用程序中托管一个 Wordpress 博客。

于 2015-04-14T13:35:00.467 回答
3

您可以使用多种选项在应用程序中存储文件。它们都不包括在应用程序容器文件系统中执行此操作,因为文件空间是短暂的,并且每次创建应用程序的新实例时都会从液滴中重新创建。

您可以使用 MongoLab、Cloudant、Object Storage 和 Redis 等服务来存储各种 blob 数据。

于 2015-04-08T01:21:51.100 回答
1

请注意,正如其他人所建议的那样,有许多用于存储对象数据的服务。转至 Bluemix 目录 [1] 并在左侧空白处选择“Data Management”。这些服务中的每一个都应该有足够的文档来帮助您入门,包括许多示例应用程序和教程。只需单击服务磁贴,然后单击“查看文档”按钮即可查找相关文档。

[1] https://console.ng.bluemix.net/?ace_base=true/#/store/cloudOEPaneId=store

于 2015-04-13T20:44:26.203 回答
0

查看https://www.ng.bluemix.net/docs/#services/ObjectStorageV2/index.html#gettingstarted。Bluemix 中的存储服务是在 Softlayer 中运行的 OpenStack Swift。查看此页面 ( http://docs.openstack.org/developer/swift/ ) 以获取有关 Swift 的文档。

这是一个列出 Swift 的一些客户端的页面。 https://wiki.openstack.org/wiki/SDKs

于 2015-04-07T14:01:01.533 回答
0

当我搜索时,有一个名为 Object Storage 服务的服务,也是由 IBM 创建的。但是,目前我在 Bluemix 目录中看不到它。我想,他们把它还给了它,将来会发布新的服务。

于 2015-12-12T17:26:32.130 回答
0

请注意,bluemix 中的 pobject 存储现在与 S3 兼容。因此,例如,您可以使用 Boto 或 boto3(对于 python 人)它将工作 100% API 兼容。在此处查看一些示例:https ://ibm-public-cos.github.io/crs-docs/crs-python.html

此脚本可帮助您以递归方式列出所有存储桶中的所有对象:

import boto3
endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'
s3 = boto3.resource('s3', endpoint_url=endpoint)
for bucket in s3.buckets.all():
    print(bucket.name)
    for obj in bucket.objects.all():
        print("  - %s") % obj.key

如果您想指定您的凭据,这将是:

import boto3
endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'
s3 = boto3.resource('s3', endpoint_url=endpoint, aws_access_key_id=YouRACCessKeyGeneratedOnYouBlueMixDAShBoard, aws_secret_access_key=TheSecretKeyThatCOmesWithYourAccessKey, use_ssl=True)

for bucket in s3.buckets.all():
    print(bucket.name)
    for obj in bucket.objects.all():
        print("  - %s") % obj.key

如果要在新存储桶中创建“hello.txt”文件。:

import boto3
endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'
s3 = boto3.resource('s3', endpoint_url=endpoint, aws_access_key_id=YouRACCessKeyGeneratedOnYouBlueMixDAShBoard, aws_secret_access_key=TheSecretKeyThatCOmesWithYourAccessKey, use_ssl=True)
my_bucket=s3.create_bucket('my-new-bucket')
s3.Object(my_bucket, 'hello.txt').put(Body=b"I'm a test file")

如果要在新存储桶中上传文件:

import boto3
endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'
s3 = boto3.resource('s3', endpoint_url=endpoint, aws_access_key_id=YouRACCessKeyGeneratedOnYouBlueMixDAShBoard, aws_secret_access_key=TheSecretKeyThatCOmesWithYourAccessKey, use_ssl=True)
my_bucket=s3.create_bucket('my-new-bucket')
timestampstr = str (timestamp)
s3.Bucket(my_bucket).upload_file(<location of yourfile>,<your file name>, ExtraArgs={ "ACL": "public-read", "Metadata": {"METADATA1": "resultat" ,"METADATA2": "1000","gid": "blabala000", "timestamp": timestampstr },},)
于 2016-12-21T08:21:53.077 回答