Comments (6)
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.
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.
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.
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.
Would it be possible to create a pull request? If not I'll put it in there.
from salesforcemagic.
Added and closed with 09f475a
from salesforcemagic.
Related Issues (20)
- Readonly Attribute HOT 1
- Nullable fields (specifically datetime) HOT 1
- Write better documentation
- DateTime conversions yield inconsistent results because of UTC HOT 3
- Metadata query? HOT 2
- Error encountered using client.Insert<T>() - Organization ID: id value of incorrect type HOT 4
- Malformed query HOT 3
- Some fields are valid to supply when inserting, but are not allowed to be updated. HOT 5
- Insert is broken
- No handling for ApiFault classes, ExceptionCode enum HOT 1
- Salesforce has disabled TLS 1.0 HOT 2
- Login failing on a Production Instance
- Profile259 build
- Add api calls
- Implement offset in queries
- Add count feature HOT 1
- Implement better raw query and raw data mapping.
- Add exception handling for 400 Bad Request
- Batch errors not mapped
- Query values need to be escaped HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from salesforcemagic.