Object Storage File Uploads
I am able to upload files using the Typescript SDK using my web browser and the cloud web app, as well as, the typescript SDK. When a .css file is uploaded via the browser, it correctly has the Content Type: text/css however when I perform the upload via a script of the EXACT same file, the result is a Content Type:application/octet-stream and the file is of no use. I can't load it as CSS.
The code I am using is unmodified straight from the example. and it works perfectly, except for this issue. Im making sure to NOT do a multi part upload, and in fact the console prints out
Calling operation ObjectStorageClient#putObject.
Retry policy to use: MaximumNumberAttempts=undefined, MaxSleepBetween=30, ExponentialBackoffBase=2
Total Latency for this API call is: 189 ms
uploading using single upload
Which seems like it should not be "streaming" the file and instead doing a simple PUT.
PLEASE PLEASE PLEASE if anyone can help me. I really am liking oracle's cloud stuff and I want to get this to work.
const common = require("oci-common");
const os = require("oci-objectstorage");
// import { basename, join } from "path";
const { basename, join } = require("path");
// import { readdir } from "fs";
const { readdir } = require("fs");
const provider = new common.ConfigFileAuthenticationDetailsProvider();
const client = new os.ObjectStorageClient({ authenticationDetailsProvider: provider });
const uploadManager = new os.UploadManager(client, { enforceMD5: true });
const directoryPath = "./css"
const namespaceName = "blahblah"
const bucketName = "example-012724"
(async () => {
// Read files from the directory
readdir(directoryPath, (err, files) => {
if (err) return console.log("Unable to scan directory: " + err);
files.forEach(async filename => {
const objectName = `${basename(filename)}`;
console.log(`Uploading ${objectName}`);
try {
console.time("Upload Time");
const callback = res => {
console.log("Progress: ", res);
};
await uploadManager.upload(
{
content: {
filePath: join(directoryPath, filename)
},
requestDetails: {
namespaceName: namespaceName,
bucketName: bucketName,
objectName: objectName
}
},
callback
);
console.timeEnd("Upload Time");
} catch (ex) {
console.error(`Failed due to ${ex}`);
}
});
});
})();