谷歌云存储公共网址,在img src中使用

时间:2014-09-23 05:28:43

标签: google-cloud-storage

首先,我已阅读,搜索谷歌和所有地方。但我无法找到解决问题的方法。我可以将图片上传到我的谷歌云存储桶。然后,我想获取公共URL,所以我可以将它保存到我的mongodb,稍后访问我的网站。

我这里有一个代码,用GO编写。

// profile func, that receive filename, and file
name, self_link, err := google_storage.Upload(handler.Filename, file)

// then after acquiring the self_link, i update the user
db.UpdateUser(session_id.(string), db.UserUpdate{"ProfileImage": self_link})

问题是,在将文件传递给html时,我无法从链接到我的网页访问该文件。

我猜,我的链接不公开?

这是我的oauth配置

config := &oauth.Config{
    ClientId:     clientId,
    ClientSecret: clientSecret,
    Scope:        storage.DevstorageFull_controlScope,
    AuthURL:      "https://accounts.google.com/o/oauth2/auth",
    TokenURL:     "https://accounts.google.com/o/oauth2/token",
    TokenCache:   oauth.CacheFile(cacheFile),
    RedirectURL:  "https://www.example.com/oauth2callback",
    AccessType:    "offline",
}
在授权我的网络服务器后,从那里

,我可以

// my object setup
object_to_store_data := &storage.Object{Name: fileName}

result, err := service.Objects.Insert(bucketName, storage_data).Media(file).Do()

任何帮助表示赞赏,谷歌云存储新手,然后去。

提前谢谢

0 个答案:

没有答案
相关问题