Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot upload a file in nodejs #177

Open
Raffaello opened this issue May 23, 2022 · 2 comments
Open

cannot upload a file in nodejs #177

Raffaello opened this issue May 23, 2022 · 2 comments

Comments

@Raffaello
Copy link

Raffaello commented May 23, 2022

Describe the bug
Uploading a file is returning 404 when using nodejs.

To Reproduce

import { Storage } from "@google-cloud/storage";

const host = "localhost:9023";
  process.env.STORAGE_EMULATOR_HOST = host;
const bucket =  "my-bucket";
  const filename =  "my-file";
  const filepath = "file.txt";
  const storage = new Storage();
storage.bucket(bucket_name).upload(filePath, { destination: filename });

Expected behavior
A clear and concise description of what you expected to happen.

System (please complete the following information):

  • OS version: linux fedora 36
  • version: (node 16.13.2)
  • gcp-storage-emulator version: (latest)

Additional context
the log producted by the emulator:

"POST /upload/storage/v1/b/my-bucket/o?uploadType=multipart&name=my-file HTTP/1.1" 404 -

the file to be uploaded exists.

I didn't have this issue 2 weeks ago or so.

also when creating a bucket there is this log error reported by the emulator:

Method not implemented: POST - /b
"POST /b?project=my-project HTTP/1.1" 501 -

with python instead looks like is working smoothily.
Honestly i don't understand why as the API should be the same.

@Raffaello
Copy link
Author

Raffaello commented May 23, 2022

i think the problem is also due to the 501 on create bucket:

const bucketResp = await storage.createBucket(bucket_name);

@karlkristopher
Copy link

import { Storage } from "@google-cloud/storage";

const host = "localhost:9023";
  process.env.STORAGE_EMULATOR_HOST = host;
const bucket =  "my-bucket";
  const filename =  "my-file";
  const filepath = "file.txt";
  const storage = new Storage();
storage.bucket(bucket_name).upload(filePath, { destination: filename });

@Raffaello I believe you should set host to http://localhost:9023/storage/v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants