<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:36:38 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[GODRIVER-1548] Access filename and metadata in gridfs DownloadStream</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-1548</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;The api for gridfs does not give you access to the filename or metadata of a file when downloading it even though internally it fetches the file document. I propose adding fields or methods to access these on `DownloadStream` and internally just linking up to the file document which is already fetched. This would prevent user libraries from having to implement this and also from having to redundantly lookup the file document(ie read from the db again).&lt;/p&gt;

&lt;p&gt;Our app uses file ids to lookup files but we use the name and metadata(contenttype stored here) to provide a more friendly url to the user. While upgrading from globalsign/mgo I found that the gridfs implementation here doesn&apos;t give you any way to read file names or metadata easily. Right now you have to hack around it by fetching the file again and decoding it yourself.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1292958">GODRIVER-1548</key>
            <summary>Access filename and metadata in gridfs DownloadStream</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="divjot.arora@mongodb.com">Divjot Arora</assignee>
                                    <reporter username="epelc@greatcloak.com">Ed Pelc</reporter>
                        <labels>
                    </labels>
                <created>Thu, 26 Mar 2020 20:57:02 +0000</created>
                <updated>Sat, 28 Oct 2023 11:38:15 +0000</updated>
                            <resolved>Thu, 2 Apr 2020 21:21:10 +0000</resolved>
                                                    <fixVersion>1.4.0</fixVersion>
                                    <component>GridFS</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3024168" author="xgen-internal-githook" created="Thu, 2 Apr 2020 21:20:51 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Divjot Arora&apos;, &apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1548&quot; title=&quot;Access filename and metadata in gridfs DownloadStream&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1548&quot;&gt;&lt;del&gt;GODRIVER-1548&lt;/del&gt;&lt;/a&gt; Add gridfs.File type (#353)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/32066eda51e9c1f24d28b83fbb90b59d793eecdf&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/32066eda51e9c1f24d28b83fbb90b59d793eecdf&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3023819" author="divjot.arora" created="Thu, 2 Apr 2020 18:53:45 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/pull/353&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/pull/353&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3019203" author="epelc@greatcloak.com" created="Tue, 31 Mar 2020 15:14:47 +0000"  >&lt;p&gt;Awesome! Thanks for this!&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;This really simplifies upgrading gridfs. Will be nice to tear out my workaround.&lt;/p&gt;</comment>
                            <comment id="3019199" author="divjot.arora" created="Tue, 31 Mar 2020 15:14:06 +0000"  >&lt;p&gt;Now that we&apos;ve reached an agreement about the best way to proceed with this, I&apos;m going to move it from &quot;Investigating&quot; to &quot;Scheduled&quot;. We will complete the work and release this in the 1.4.0 driver release. Thank you for the quick responses and ideas!&lt;/p&gt;

&lt;p&gt;&amp;#8211; Divjot&lt;/p&gt;</comment>
                            <comment id="3019191" author="divjot.arora" created="Tue, 31 Mar 2020 15:12:16 +0000"  >&lt;p&gt;Yeah, interface{} isn&apos;t correct because that&apos;d be unmarshalled as a bson.D (the driver defaults to bson.D, whereas mgo defaults to bson.M because bson.D is an ordered type and therefore inherently safer). Because the metadata field is guaranteed to be a document, we can keep it as a bson.Raw, which is the raw bytes comprising a BSON document and a user can safely call bson.Unmarshal. I like this because this limits the performance overhead for someone who just needs to access one field, but also allows you to easily unmarshal the whole thing into a custom Go type if needed.&lt;/p&gt;</comment>
                            <comment id="3019183" author="epelc@greatcloak.com" created="Tue, 31 Mar 2020 15:09:15 +0000"  >&lt;p&gt;That would work you just have to be sure the underlying data is not auto unmarsahlled into something generic like a bson.M before it gets to the user code.&lt;/p&gt;

&lt;p&gt;That is much cleaner too! Good idea.&lt;/p&gt;</comment>
                            <comment id="3019176" author="divjot.arora" created="Tue, 31 Mar 2020 15:07:34 +0000"  >&lt;p&gt;If the metadata was kept as interface{}, would it be the same to have the user call &lt;tt&gt;bson.Unmarshal(file.Metadata, &amp;amp;result)&lt;/tt&gt;?&lt;/p&gt;</comment>
                            <comment id="3019166" author="epelc@greatcloak.com" created="Tue, 31 Mar 2020 15:05:02 +0000"  >&lt;p&gt;I think that would work well! Is there anyway we could support unmarshalling the metadata into a go struct or other custom type instead of just getting back a `bson.M` or similar? This would make it easy to have a full object/nested fields or any other custom data and make the metadata have full power vs having to again do a separate file lookup using regular `FindOne().Decode()`.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Almost like you&apos;d make an `UnmarshalMetadata(&amp;amp;userSuppliedOutVar)` method on the `GridFSFile` type instead of the java version which returns a Document(similar to bson.M?)&#160;&lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/4.0/apidocs/mongodb-driver-core/com/mongodb/client/gridfs/model/GridFSFile.html?is-external=true#getMetadata()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://mongodb.github.io/mongo-java-driver/4.0/apidocs/mongodb-driver-core/com/mongodb/client/gridfs/model/GridFSFile.html?is-external=true#getMetadata()&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know the current implementation basically pulls out the name and id field without unmarshalling the entire document so I&apos;d assume it&apos;d be simple to delay the metadata unmarshalling.&lt;/p&gt;</comment>
                            <comment id="3019068" author="divjot.arora" created="Tue, 31 Mar 2020 14:30:55 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=epelc%40greatcloak.com&quot; class=&quot;user-hover&quot; rel=&quot;epelc@greatcloak.com&quot;&gt;epelc@greatcloak.com&lt;/a&gt; Thank you for the detailed feature request! Instead of multiple methods on &lt;tt&gt;DownloadStream&lt;/tt&gt; to access each piece of file information, I propose adding a new &lt;tt&gt;gridfs.File&lt;/tt&gt; type and a &lt;tt&gt;DownloadStream.GetFile&lt;/tt&gt; method to return the file being downloaded. These would be similar to the &lt;tt&gt;GridFSFile&lt;/tt&gt; type and &lt;tt&gt;GridFSDownloadStream.getGridFSFile()&lt;/tt&gt; method in the Java driver (see&#160;&lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/4.0/apidocs/mongodb-driver-core/com/mongodb/client/gridfs/model/GridFSFile.html?is-external=true&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://mongodb.github.io/mongo-java-driver/4.0/apidocs/mongodb-driver-core/com/mongodb/client/gridfs/model/GridFSFile.html?is-external=true&lt;/a&gt;&#160;and&#160;&lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/4.0/apidocs/mongodb-driver-sync/com/mongodb/client/gridfs/GridFSDownloadStream.html#getGridFSFile()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://mongodb.github.io/mongo-java-driver/4.0/apidocs/mongodb-driver-sync/com/mongodb/client/gridfs/GridFSDownloadStream.html#getGridFSFile()&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Does this sound like a reasonable proposal to you?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="711328">GODRIVER-863</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hvaolr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>