怎样才能获得“幸福”呢?使用 Grails 的 Amazon S3 插件命名(通过 Jets3t)
参考文献:
- http://www.grails.org/plugin/amazon-s3
- < a href="http://svn.codehaus.org/grails-plugins/grails-amazon-s3/trunk/grails-app/services/org/grails/s3/S3AssetService.groovy" rel="nofollow noreferrer">http ://svn.codehaus.org/grails-plugins/grails-amazon-s3/trunk/grails-app/services/org/grails/s3/S3AssetService.groovy
- http://svn.codehaus.org/ grails-plugins/grails-amazon-s3/trunk/grails-app/domain/org/grails/s3/S3Asset.groovy
我所说的“快乐”名称是指我正在上传的文件的真实名称。 .. 例如,如果我要放置一个名为“foo.png”的文件,我希望该文件的 url 为 /foo.png。目前,我只是获取文件名的 GUID(没有文件扩展名)。
有什么想法吗?
References:
- http://www.grails.org/plugin/amazon-s3
- http://svn.codehaus.org/grails-plugins/grails-amazon-s3/trunk/grails-app/services/org/grails/s3/S3AssetService.groovy
- http://svn.codehaus.org/grails-plugins/grails-amazon-s3/trunk/grails-app/domain/org/grails/s3/S3Asset.groovy
By "happy" names, I mean the real name of the file I'm uploading... for instance, if I'm putting a file called "foo.png" I'd expect the url to the file to be /foo.png. Currently, I'm just getting what appears to be a GUID (with no file extension) for the file name.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在S3Asset对象上设置关键字段来实现您的需要。
我将更新 doco 页面并提供更多相关信息。
You can set the key field on the S3Asset object to achieve what you need.
I'll update the doco page with more information on this.
通过上传文件中给出的
length
、inputstream
和fileName
,您应该使用以下代码实现您想要的:我希望它有所帮助。
With
length
,inputstream
andfileName
given from the uploaded file, you should achieve what you want with the following code :I hope it helps.
实际解决方案(由@leebutts提供):
Actual solution (as provided by @leebutts):