pushing changes in deployment
my project is deployed via github and it writes to the working directory, these changes are supposed to be able to get pushed but when i try
git push
, it says fatal: not a git repository (or any of the parent directories): .git
Solution:Jump to solution
not the best approach, you would want to be using object storage like cloudflare r2
54 Replies
Project ID:
f1e43e9b-5ebf-4488-a4aa-65930dcaccd1
im sorry but i dont see how issues with git on your local computer has anything to do with railway
?
i'm talking about railway
none of this is on my computer
git push
is a command you run on your computer
am i wrong there?it's part of my code
my code runs git push
why would you want to do that?
to sync a specific file with the repo on github?
Solution
not the best approach, you would want to be using object storage like cloudflare r2
thanks
i will check it out
can i integrate it with railway
you would intigrate it with your code using the amazon s3 sdk
thanks
works beautifully, thanks so much
used rclone
now hold on
are you using rclone in the same fashion that you where using git push?
i'm using rclone-python, so no
i would recommend against that, the best way would be using the r2 api directly with boto3
using the api directly with the boto3 package is way less error prone, faster, more portable then calling out to the shell to run rclone commands
boto3 seems complicated
it's worth it, trust me
i'll give it a shot later
@Brody i think i figured it out
but when i upload
the type isn't text/plain
I think you can specify the mime type in extra args
hmm
contenttype?
content type
will try
works
what about charset?
just set
ContentType
= text/plain; charset=utf-8
oh ok
tysm
no problem!
you are using environment variables for the storage credentials right?
was doing a local test, but for railway i'll use the environment variables
perfect!
to download objects, should i use copy_object or get_object?
get
ok
hmm
format is confusing
format?
to upload it's
s3.Bucket("bucket").put_object(Key="file.txt", Body=open("file.txt", "rb"), ContentType="text/plain; charset=utf-8")
i don't know how it is for downloading thoughdownload_object, get_object
something along those lines, but that's what the documentation is for
i'm getting a
AttributeError: 's3.Bucket' object has no attribute 'get_object'. Did you mean: 'put_object'?
link me the documentation you've been using
oh figured it out i think
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/get_object.html
it's an attribute on the client, not bucket
how do i use it then?
scroll down on this page, it shows you all the available arguments
oh i had a typo in my filename
lol
lol
this works
perfect
s3 is defined as
now just to swap over to service variables
then you can run your app locally with the railway service variables available by using
railway run
alright
can i also set endpoint_url using an environment variable?
yes of course
alright
railway run works well
awesome