Git Product home page Git Product logo

Comments (6)

briannewbold avatar briannewbold commented on August 30, 2024

Yep.. I'm stuck. HELP PLEASE!

I can get a file uploaded into the attachments object, but SFDC only gets 6 bytes of the otherwise 480kb .pdf file.

Any help would be appreciated! I just used a standard FileStream to read my text file data into byteArray.

            Attachment[] attachment = new[]
            {
                new Attachment
                {
                    FileName = "test1.pdf",
                    Description = "TestUploadFile1",
                    ParentID = "800i0000000BJYqAAO",
                    Body = byteArray,
                    ContentType = ".pdf"
                }
            };

            CrudOperation<Attachment> myInsertOperation = new CrudOperation<Attachment>();
            myInsertOperation.OperationType = CrudOperations.Insert;
            myInsertOperation.Items = attachment;

            SalesforceResponse response = client.Crud<Attachment>(myInsertOperation);

Do you mind throwing an example on GitHub that shows basic upload?

Thanks!!

from salesforcemagic.

michael-shattuck avatar michael-shattuck commented on August 30, 2024

Sorry for the delay in response. My wife just gave birth to our first child and things have been a little crazy. Let me take a look into the code. I suspect it isn't fully supported yet. If it isn't I can add it in.

from salesforcemagic.

briannewbold avatar briannewbold commented on August 30, 2024

Wow! Congratulations!

Certainly no hurry on this one, take care of that baby. :-)

Cheers and thanks,

Brian

On Mon, Oct 13, 2014 at 2:26 PM, Michael Shattuck [email protected]
wrote:

Sorry for the delay in response. My wife just gave birth to our first
child and things have been a little crazy. Let me take a look into the
code. I suspect it isn't fully supported yet. If it isn't I can add it in.


Reply to this email directly or view it on GitHub
#3 (comment)
.

from salesforcemagic.

briannewbold avatar briannewbold commented on August 30, 2024

Fixed it... but please review and push to your prdn code if you could:
In SObject.cs

    public void WriteXml(XmlWriter writer)
    {
        // TODO: Implement more robust serialization
        Type type = GetType();
        TypeAccessor accessor = ObjectHydrator.GetAccessor(type);
        writer.WriteElementString("type", type.GetName());

        foreach (PropertyInfo info in type.GetProperties())
        {
            var value = accessor[this, info.Name];
            if (value == null) continue;
            string xmlValue = value is DateTime 
                ? ((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ssZ")
                : value.ToString();

            //Added additional routine for when value is Byte[] ---bnewbold 22OCT2014
            if (value.ToString() == "System.Byte[]") 
            {
                //When value is passed in a byte array, as when uploading a filestream file, we need to read the value in rather than cast it to a string.
                byte[] byteArray = (byte[]) value;  //Cast value as byte array into temp variable
                writer.WriteStartElement(info.GetName()); //Not using WriteElementsString so need to preface with the XML Tag
                writer.WriteBase64(byteArray, 0, byteArray.Length); //Just use base64 XML Writer
                writer.WriteEndElement(); //Close the xml tag
                continue;
            };
            //END OF ADDITIONAL ROUTINE
            writer.WriteElementString(info.GetName(), SalesforceNamespaces.SObject, xmlValue);
        }
    }

from salesforcemagic.

michael-shattuck avatar michael-shattuck commented on August 30, 2024

Would it be possible to create a pull request? If not I'll put it in there.

from salesforcemagic.

michael-shattuck avatar michael-shattuck commented on August 30, 2024

Added and closed with 09f475a

from salesforcemagic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.