<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:07 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>[JAVA-367] java bson exception while reading files from gridfs (that was storead by php driver)</title>
                <link>https://jira.mongodb.org/browse/JAVA-367</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi.&lt;br/&gt;
My system is writen on php and java.&lt;br/&gt;
I started testing php and java drivers to communicate with GridFs.&lt;br/&gt;
I can store and get files with php, and so with java, but&lt;br/&gt;
when I store a file with php in GridFs and then want to get and write it to fs with java it fails:&lt;/p&gt;

&lt;p&gt;java.lang.ClassCastException: org.bson.types.Binary cannot be cast to [B&lt;br/&gt;
        at com.mongodb.gridfs.GridFSDBFile.getChunk(GridFSDBFile.java:89)&lt;br/&gt;
        at com.mongodb.gridfs.GridFSDBFile.writeTo(GridFSDBFile.java:75)&lt;/p&gt;

&lt;p&gt;but when with java and then with php, everything ok.&lt;/p&gt;

&lt;p&gt;sample code i am using:&lt;/p&gt;

&lt;p&gt;     PHP WRITE CODE&lt;/p&gt;

&lt;p&gt;     $m = new Mongo();&lt;br/&gt;
     $fs = $m-&amp;gt;test-&amp;gt;getGridFs();&lt;br/&gt;
     echo $fs-&amp;gt;storeFile(&quot;J:&lt;br class=&quot;atl-forced-newline&quot; /&gt;1.avi&quot;, array(&apos;filename&apos; =&amp;gt; &apos;filename1&apos;), array(&apos;safe&apos; =&amp;gt; true));&lt;/p&gt;


&lt;p&gt;     JAVA READ CODE&lt;/p&gt;

&lt;p&gt;       GridFS myFS;&lt;br/&gt;
        try {&lt;br/&gt;
            myFS = new GridFS(new Mongo().getDB(&quot;test&quot;));&lt;br/&gt;
            GridFSDBFile f = myFS.findOne(&quot;filename1&quot;);&lt;br/&gt;
            if(f!=null)&lt;/p&gt;
{
                f.writeTo(&quot;J:\\res.txt&quot;);
                System.out.println(&quot;true&quot;);
            }
&lt;p&gt;else&lt;/p&gt;
{
                System.out.println(&quot;false&quot;);
            }
&lt;p&gt;            &lt;br/&gt;
        } catch (Exception ex) &lt;/p&gt;
{
            Logger.getLogger(Ufs.class.getName()).log(Level.SEVERE, null, ex);
        }


&lt;p&gt;   ps&lt;/p&gt;

&lt;p&gt;   I danced a lot with this code, modified parameters, changed ids, php and java drivers on older versions. Nothing helped.&lt;br/&gt;
   And java gets file by id fine, but when saving getting exception.&lt;/p&gt;

&lt;p&gt;   What I am doing wrong ?   &lt;/p&gt;

&lt;p&gt;   Thanks.&lt;/p&gt;

























</description>
                <environment>windows, db: mongodb-win32-i386-1.8.1, php driver: mongo-1.1.4-WINDOWS, java: mongo-2.6.1.jar</environment>
        <key id="17821">JAVA-367</key>
            <summary>java bson exception while reading files from gridfs (that was storead by php driver)</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="alezozov">alezozov</reporter>
                        <labels>
                            <label>bson</label>
                            <label>crash</label>
                    </labels>
                <created>Thu, 2 Jun 2011 19:42:39 +0000</created>
                <updated>Wed, 11 Sep 2019 19:12:50 +0000</updated>
                            <resolved>Thu, 2 Jun 2011 21:23:58 +0000</resolved>
                                    <version>2.6.1</version>
                                    <fixVersion>2.6.2</fixVersion>
                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="35831" author="antoine" created="Thu, 2 Jun 2011 21:23:37 +0000"  >&lt;p&gt;This is due to bug &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-368&quot; title=&quot;When reading back binary of type B_GENERAL (2) Java driver creates a Binary object which breaks some driver and user code&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-368&quot;&gt;&lt;del&gt;JAVA-368&lt;/del&gt;&lt;/a&gt;.&lt;br/&gt;
Fix will be available with 2.6.2 to be released probably today.&lt;br/&gt;
If you use an older driver (e.g. 2.5.3) it should work fine.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="17830">JAVA-368</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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="10012"><![CDATA[Major Change]]></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|hrhc0v:</customfieldvalue>

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