Comments (6)
You forgot to reset the position of the memory stream :p.
from catbox.net.
Unfortunately even with resetting it back to 0 the same error happens
memoryStream.Seek(0, SeekOrigin.Begin);
or memoryStream.Position = 0;
Which I find very weird
from catbox.net.
Can you post the code when you reset the position to 0 ?
from catbox.net.
public async Task<string?> UploadImageAsync(Stream memoryStream, string fileName) {
memoryStream.Seek(0, SeekOrigin.Begin);
return await CatBoxClient.UploadImage(new CatBox.NET.Requests.StreamUploadRequest() {
Stream = memoryStream,
FileName = fileName,
UserHash = UserHash,
});
}
Tried both .Position and Seek, also tried instantiating a new memorystream beforehand incase the parameter was making the copy and not persisting on passing it. I must be doing it wrong for sure lol. I have also tried doing it before calling this instead of from within. But console says position is 0 all the time, before calling UploadImageAsync
from catbox.net.
After digging deeper and losing my mind for a bit, I have finally figured it out. Yes, my code was functional it had nothing to do with the code. Catbox.moe requires you to have a user agent set otherwise it closes the connection. Perhaps it was a recent addition. I solved this by injecting a user agent into the http client. I think the library should be updated to include a user agent by default. I am not sure if it accepts any user agent so you can give it a unique UA, or if it only accepts known ones like chrome, edge, firefox... etc.
But yea, that's how to fix the problem.
from catbox.net.
I'll look into this soon. If that's the case, maybe it's been a recent addition or change to their API because I haven't seen anything related to setting a user agent in the documentation they have.
from catbox.net.
Related Issues (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 catbox.net.