Comments (9)
Hey @Huljo. At the moment this is not possible, you can only upload using the file itself. @osener @GuilhermeSCP is this something we could have a look into?
from bynder-js-sdk.
@Huljo thank you for the test case, you're absolutely right. We will release a fix as soon as possible.
Have a great weekend!
from bynder-js-sdk.
Hey @Huljo!
Indeed it should be possible, the SDK should be able to understand what type of file you're passing and parse it accordingly. Let us know if something doesn't work.
from bynder-js-sdk.
Hey @GuilhermeSCP and @danielsequeira,
I didn't found any example about it so I tryed this way (based on uploadFile example here) :
const fs = require('fs');
const path = require('path');
const Bynder = require('@bynder/bynder-js-sdk').default;
const bynderConfig = {
consumer: {
public: '********',
secret: '********',
},
accessToken: {
public: '********',
secret: '********',
},
"baseURL": "https://********.getbynder.com/api/"
};
const bynder = new Bynder(bynderConfig);
bynder.getBrands()
.then((data) => {
const brand = data[0];
const file = `${__dirname}/testasset.png`;
return bynder.uploadFile({
filename: path.basename(file),
body: fs.createReadStream(file),
data: {
brandId: brand.id,
name: 'test asset'
}
});
})
.then(console.log)
.catch((error) => {
console.error(error);
});
It throw me an error related to the file length :
{ status: 0,
message: 'The upload length is not valid or it was not specified properly' }
Where can I find the documentation about this method ?
Thank you guys for the support.
from bynder-js-sdk.
Just took a new look and you're right, that case is not entirely covered, I'll reopen and escalate the issue. Thanks for letting us know!
from bynder-js-sdk.
I added a property length to uploadFile options ( bynder.uploadFile({..., length:[int], ...}) ). The upload is working now but I have to get the total file length before using uploadFile.
Not sure if it is uploading every stream chunks on the fly or if it's waiting the entire file to push chunk separately. (Since Im working on AWS Lambdas I cant work with FS so I need the first behavior)
from bynder-js-sdk.
@Huljo we've investigated possibilities for allowing this, but unfortunately our uploads API has to know the number of chunks ahead of time. I'm afraid we can't address this until Bynder gets a new API for uploads. We'll keep you posted if we hear about any plans for this.
For now, I suggest getting the length of your source file yourself. Since how to do this depends on the type of the stream, I don't think we'll implement this in the SDK.
You mentioned you won't be using fs
, but if you can read the file size via the ContentLength
property of S3.getObject
response or content-length
response header of an HTTP stream it should do the trick.
Let us know if you have further questions.
from bynder-js-sdk.
Thank you for the quick reply @osener .
Using content-length
from S3.getObject
do the trick for me.
Everything looks ready to handle stream data using the SDK. There is just a lack of information about how to use it. Maybe you should plan to create an example using length property in uploadFile options or a short documentation.
from bynder-js-sdk.
Noted 👍. Happy to hear you got it working!
from bynder-js-sdk.
Related Issues (19)
- TypeError: joinUrl is not a function
- Overwrite media or add a new version? HOT 1
- Release new version on npm repository HOT 1
- Missing OAuth Client Credentials HOT 1
- Page scroll block breaks Bynder scroll HOT 1
- bynder-js-sdk node upgrade HOT 1
- Run tests and linter in CI HOT 1
- dist directory missing with 1.1.0 release HOT 4
- Upgrade to axios 0.19.0 HOT 2
- Typescript support HOT 2
- Return Chunk Upload and Number of Chunk HOT 2
- OAuth2 permanent token not working HOT 5
- Stalling asset uploads HOT 1
- uploadFile seems to be too slow HOT 5
- v2.3.0 is not marked as latest release HOT 1
- Metaproperties seem not to be transmitted when uploading an asset.
- API calls fail when payload contains values with ampersands in them HOT 3
- Permanent tokens doesn't seem to work. HOT 4
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 bynder-js-sdk.